请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
我在 ARM Cortex-M4处理器上编写嵌入式 C 程序。 我已将 MATLAB 中的数据保存在.txt 文件中、并希望在 C 代码中读取相同的数据。 当我使用 fopen()函数时,会出现 “无法从非基元位置加载”错误。 有人能告诉我我我出了什么问题吗?
FILE *fp = fopen("x_real.txt","r"); Getting NULL pointer here
// Return if could not open file
if (fp == NULL)
{
printf("Could not open the file");
return 0;
}
do
{
// Taking input single character at a time
char c = fgetc(fp);
// Checking for end of file
if (feof(fp))
break ;
printf("%c", c);
} while(1);
fclose(fp);
