第1个回答 2014-06-05
int main()
{
char mystring [100]={0};
int cur=0; char str[10][100]={0};int num1[10],num2[10];
FILE* pFile = fopen ("2.txt" , "r");
if (pFile == NULL) perror ("Error opening file");
else {
while(!feof(pFile))
{
fgets (mystring , 100 , pFile);
sscanf(mystring,"%s %d %d",str[cur],num1+cur,num2+cur);
++cur;
}
}
for(int i=0;i<cur;++i)
printf("%s %d %d\n",str[i],num1[i],num2[i]);
}