I am working on a program to change take a word or multiple words from the user(at most 100 characters). for example if the user put in dakka dakka, they would get d@kk@ d@kk@ printed out. I am doing something wrong and it only prints the first word of what I type.
#include <stdio.h>
#include <string.h>
int main()
{
char utext[100];
int i, len;
char c;
len = strlen(utext);
printf("type in your message to be converted: \n");
fgets( utext, 100, stdin );
for ( i = 0; i < len; ++i )
{
c = utext[i];
if (c == 'a')
c = '@';
printf("%c", c);
}
return 0;
}
strlenonly after you have read the string.fgets( utext, 100, stdin );toif (NULL==fgets( utext, sizeof(utext), stdin)) return -1;