A Small C question for you, appreciate your help:
A file's first line is:
"add A"
It has more lines beneath.
I'm reading the first line from the file using fgets:
char str [500];
fgets(str,sizeof(str),filePointer);
Since fgets stops at the newline char, I replace the unwanted newline char with '\0':
char *p;
if ((p = strchr(str, '\n')) != NULL)
*p = '\0';
Now if I print str this way:
printf("DEBUG: str:=[%s]\n",str);
Why do I get a crappy output like this:
]EBUG: str:=[add A
and not:
DEBUG: str:=[add A]
??
Thanks!!
strin the debugger. You will see something interesting. - Raymond Chenhexdumpto look at your output in hex. Or to look at your input in hex, for that matter. - rici