-4
我試圖從一個文件異常在project.exe在0x5409B211(ucrtbased.dll)拋出:0000005:訪問衝突寫入位置0x007110E8
填充結構包括hashtag數組的hash_name的結構包括hashtag是
typedef struct{
char hash_name[300];
long hash_freq;
ID_liste users;
}hashtag;
我的載體作用是
void load_hashtag(long ID,int* taille,hashtag *local)
{
int i=-1;
char filename[100];
sprintf(filename, "data\\fn\\%d.featnames", ID);
long a;
FILE * g=fopen(filename,"r");
do{
if (i >= 0)
{
local = (hashtag*)realloc(local, sizeof(hashtag));
printf("realloc %d\n", i);
}
i++;
fscanf(g,"%ld",&a); //a numbre i don't want
fseek(g, 2, SEEK_CUR); //tow characters i don' want
fscanf(g, "%s", local[i].hash_name);
}while(!feof(g));
fclose(g);
*taille = i;
}
主要是
int main()
{
int i,j;
hashtag* local = (hashtag*)malloc(sizeof(hashtag));
int local_taille;
long ID_user;
FILE* user;
user = fopen("User.txt", "r");
if (user == NULL)
{
printf("Error opening file\n");
return 0;
}
fscanf(user, "%ld", &ID_user);
load_hashtag(ID_user,&local_taille,local);
fclose(user);
system("Pause");
return 0;
}
之後,從1300 50的fscanf程序停止和異常拋出窗口出現
請幫助
使用調試器。 – kaylum
OT:這個'... fn \\%d.featnames「,ID);'應該是'... fn \\%ld.featnames」,ID);''作爲'ID'是'long'。 – alk