I am puzzled by the following difference in behavior:
// suppose myfile.txt contains a single line with the single character 's' errno_t res; FILE* fp; char cmd[81]; res = fopen_s(&fp, "D:\\myfile.txt", "rb" ); fscanf(fp,"%80s",cmd); // cmd now contains 's/0' fclose(fp); res = fopen_s(&fp, "D:\\myfile.txt", "rb" ); fscanf_s(fp,"%80s",cmd); // cmd now contains '/0' ! fclose(fp);
The results do not depend on the order of the call (i.e. first call fscanf_s, first you will get an empty string). Compiled on VC ++ - VS2005. Can anyone reproduce? Can someone explain?
Thanks!
c ++ visual-c ++ crt visual-studio-2005
Ofek shilon
source share