69,369
社区成员
发帖
与我相关
我的任务
分享
FILE *f;
int i=0;
char str[20];
if((f=fopen("name.txt","r"))==NULL)
{
printf ("文件打开失败!\n");
exit(0);
}
while(!feof(f))
{
fscanf(f,"%s",&str);
G->school[i].name= new char[strlen(str)+2];
strcpy(G->school[i].name, str);
// G->edges[i][j]=G->edges[j][i]=k;
i++;
}
printf("%s",G->school[1].name);
if(fclose(f))
{
printf ("文件无法关闭!\n");
exit(0);
}