TheMillionDollarMan
Programmer
Hi.
I have a very simple file reader that I'm trying to build up (I'm from MSVC++ 6.0).
Here is the code:
char cDir[500] ;
char c;
char ctest[10];
int in = open("file.in", O_RDONLY);
while(read(in,&c,1) == 1) {
sprintf(cDir,"%c",c);
printf(cDir); //Prints out characters ok
sprintf(ctest,"%c",c);
if ( strcmp(",",ctest) == 0)
{
sprintf(cDir,"%s -man", cDir);
printf(cDir); //only prints -man. Why?????
}
}
My problem is that after the if statement cDir no longer has any characters in it. its blank. It should have whatever was read in from the file.
Why is this so?
Thanks
D