1、前言
我想要读取文件中的数据,将文件中的数据到buf 中,下面两句话报错
bool loadTrainDatafread()
{
const int MAXN = 10000000;
const int MAXS = 60 * 1024 * 1024;
char buf[MAXS];
FILE *fp = fopen("mydata.txt","r");
int len = fread(buf,1 ,MAXS, fp);
cout << "The leng of the whole len: " << 2 << endl;
// // stringstream infile(buf);
string line,tmp;
int i = 0;
}
2、解决方法
将对MAXN 和 MAXN报错的地方放到 函数外,生命为全局变量