fscanf读取不正确的值? -Xcode [英] fscanf reads incorrect value ? -Xcode
问题描述
我将File.rtf放在目录library/Developer/Xcode/DerivedData/Test(projectname)/Build/Products/Debug
中,代码似乎打开了它,但打印出了错误的输出.对于文件中的任何整数值,输出为1606422622
.
I've placed File.rtf in the directory library/Developer/Xcode/DerivedData/Test(projectname)/Build/Products/Debug
and the code seems to open it but prints out the wrong output.The output is 1606422622
for any integer value in the file.
经历类似于我的问题的解决方案,答案是将输入文件保存在正确的目录中.我想我已经做到了,但我只是无法获得正确的输出.
Going through the solutions of question similar to mine ,the answers were to get the input file in the right directory.I think I've done that but I just can't get the correct output.
迫切需要帮助.谢谢.
int main()
{
int b;
FILE *fp;
fp=fopen("File.rtf","r");
if (fp == NULL) {
printf( "File doesn't exist!\n");
}
fscanf(fp,"%i",&b);
printf("%i\n",b);
fclose(fp);
}
推荐答案
看起来像您正在尝试读取RTF格式的文件.尝试在TextEdit中将文件另存为纯文本文件". (扩展名为.txt)
Looks like you are trying to read a RTF formatted file. Try saving the file as a 'plain text file' in TextEdit. (with extension .txt)
这篇关于fscanf读取不正确的值? -Xcode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!