0
The question is as follows: Make a program that reads a text (string) typed by the user with a maximum of 500 characters. Print this text by replacing the first letter of each word with an asterisk '*'.
Read the 500 characters I managed to do:
printf("Digite uma palavra (tamanho maximo de 500 letras):");
gets(palavra);
I’m having a hard time understanding what to do. I need palavra[i]!='\0'
If you use the for
would look something like this?
for (i=0; palavra[i]!='\0' ; i++ )
{
for (i=0 ; palavra[i]<'\0'; i++ )
{
while (palavra[i]==palavra[i+1])
{
palavra[i]=' ';
achou=1;
printf ("%c\n\n", palavra[i]);
i++;
}
}
}
Don’t use
gets()
. It is impossible to use this function safely and there is another very similar function that you can replace:fgets()
. Also, the function you use is not part of the definition of the C language in the last published version (existed in C99, was removed in C11).– pmg