求助, 第一次发现printf调用数据后都能影响数据!!!!!
加了第一句printf的结果
# If you want to edit it correctly, please see
# Direction.txt
# CachePath
C:\Documents
# SavePath
F:\Videos
C:\Documents
F:\Videos
没加第一句printf的结果却是这样
C:\Documentsion
F:\Videosination?
这两句红色的是同一个printf函数打印出来的, 第一个与第二个差别确这么大. 拿到printf都能影响结果吗.代码在这里!!!!
void GetInfo(FILE *fp){ char str[128]; int count; for (count = 0; count < 1000; count++) { fgets(str, 128, fp); // 下面这句printf加与不加, 结果天壤之别. printf("%s\n", str); if (isspace(str[0]) || str[0] == '#') continue; else if (CachePath == NULL) { CachePath = malloc(strlen(str) * sizeof(char)); strncpy(CachePath, str, strlen(str) - 1); } else { SavePath = malloc(strlen(str) * sizeof(char)); strncpy(SavePath, str, strlen(str) - 1); break; } } //这里也有个pringf, 为什么这个printf受第一个影响. 不可思议. 我要疯了 printf("%s\n%s\n", CachePath, SavePath); fclose(fp);}