txt文件
(名称\吨\ tScore)
就像是:
雅各布25
托马斯48
等等
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[]){
FILE *f = fopen("skore.txt","r");
if (f==NULL){
cout << "err " <<endl;
return 1;
}
char* meno= " ";
int skore;
while(fscanf(f,"%s\t\t%d",meno, &skore ) != EOF){
cout << meno << ", " << skore << endl;
}
cin.get();
fclose(f);
return 0;
}
但是,当我运行它时:
Unhandled exception at 0x61fade8f (msvcr100d.dll) in SLDTemplate2.exe: 0xC0000005: Access violation writing location 0x0097ca4c.
1 回答
你不能尝试写一个字符串常量!