Need hep with my semantic error

while(EOF != (c = fgetc(filePtr))) 
 {

    if ((c == ' ') || (c == '\n') || (c == '\0'))
    {
        if (c == '\0')
        {
            continue;
        }
	
	printf("%s",cc);
	printf("%c\n");
	memset(cc, 0, sizeof cc);

    }
	else
	{ 
	cc=c;
	i++;
	}

I supposed from that code to print word by word from text file but there is something wrong with <<<<memset(cc, 0, sizeof cc);>>>>>
it give me like that

Post your entire code. From the look of those warnings, there may be a problem with the way you declared your variables.

You also don't ever null-terminate your array, putting a '\0' as the last character, so printf and anything else that uses strings won't know where it ends.

1 Like

ok thank you all in advance I forgot to put i=0;
to start from the first location of char array but any way can anyone help me with that little freaky symble at the end of the word

while(EOF != (c = fgetc(filePtr))) 
 {

    if ((c == ' ') || (c == '\n') || (c == '\0'))
    {
        if (c == '\0')
        {
            continue;
        }
	
	printf("%s",cc);
	printf("%c\n");
        i=0;
	memset(cc, 0, sizeof cc);

    }
	else
	{ 
	cc=c;
	i++;
	}

Post your entire code.

What is this for?

printf("%c\n");

%c means 'print one character that I passesd as an argument' but you passed no argument. It's going to print whatever garbage happens to be on the stack as %c.

1 Like

ok thank you Eng. Corona688
the mistake was

while(EOF != (c = fgetc(filePtr))) 
 {

    if ((c == ' ') || (c == '\n') || (c == '\0'))
    {
        if (c == '\0')
        {
            continue;
        }
	
	printf(cc); // don't assign it as string
	printf("%c\n");
	i=0;
	memset(cc, 0, sizeof cc);

    }
	else
	{ 
	cc=c;
	i++;
	} 
	 
	

  }

No, the wrong code is still there:

printf("%c\n"); // What will %c become?  Impossible to say!  Stack value roulette.

Also, your printf(cc); is wrong, because it will misbehave if cc happens to have % characters in it, which printf will take to be format specifiers.

Really, all you need is

printf("%s\n", cc);

which will do everything in 1 printf and behave.