a) Write a C program that reads characters from standard input and replaces every lowercase a with the "at" symbol (@) before outputting the characters to standard output. For example, if your program is called a2at, the you could use the program as follows
eg. $ echo "This is an easy problem" | ./a2at
This is @n e@sy problem
THIS IS WHAT I HAVE SO FAR:
Code:
#include <stdio.h>
#include <ctype.h>
void main()
{
int i =0;
char s[1024];
char c;
int n;
while( scanf( "%c", c))
{
s[i] = c;
i++;
}
}
for (i = 0; i < strlen(s); i++)
{
c = s[i];
if (islower(c))
{
n = n + 1;
}
printf("number of upper case letters is %d", strlen(s) - n);
}
I am stuck now, I don't what the problem is, but maybe it has something to do with the strlen? Can anyone give me a hint, thanks.