7
I have to make a program that reads a text, where each first letter of each word in the text is replaced by a character (*). I cannot compile correctly, I believe the problem is in my condition (if
).
#include <stdlib.h>
#include <string.h>
#define MAX 500
int main()
{
char text [MAX+1];
int i;
printf("Informe o texto (tamanho maximo %d caracteres:", MAX);
fflush(stdin);
gets(text);
for (i=0; i<=MAX; i++) {
if(' text[i]'==text[i]);
text[i]=' *';
}
printf(" O texto final e %s\n", text);
}
What is each first letter? First letter of a word?
– Maniero
fflush(stdin)
is only correct for Microsoft libraries (for other libraries is Undefined Behavior);gets()
is impossible to use safely. I suggest you review your program to not use these constructions.– pmg
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero