/**
Assignment name : aff_a
Expected files : aff_a.c
Allowed functions: write
--------------------------------------------------------------------------------
Write a program that takes a string, and displays the first 'a' character it
encounters in it, followed by a newline. If there are no 'a' characters in the
string, the program just writes a newline. If the number of parameters is not
1, the program displays 'a' followed by a newline.
Example:
$> ./aff_a "dubO a POIL" | cat -e
a$
$> ./aff_a "zz sent le poney" | cat -e
$
$> ./aff_a | cat -e
a$
**/
/**
$> ./filename "abc" | cat -e
a$
**/
#include <stdio.h>
#include <unistd.h>
int main(int argc, char **argv)
{
printf("%s, %s\n", argv[0], argv[1] );
//write(1, &argv[1][0], 1);
return 0;
}
/**
#include <unistd.h>
int main(int argc, char **argv)
{
while (*argv[1])
{
if (*argv[1] == 'a')
{
write(1, "a\n", 2);
return (0);
}
argv[1]++;
}
write(1, "\n", 1);
if (argc != 2)
{
write(1, "a\n", 2);
}
return(0);
}
**/
To embed this project on your website, copy the following code and paste it into your website's HTML: