真是好资源呀,一定利用好这些资源,努力学习!
void ReadList(int num[], int nLen) { FILE * fp; char szBuf[100] = " "; int nCount = 0; if((fp = fopen("record.text","r")) == NULL) {printf("读取排行榜的文件打开失败 !\n"); return; } while (fgets(szBuf, 100, fp) != NULL) { num[nCount] = atoi(szBuf); //atoi 将字符串转换为整形数字 nCount++; //printf("这里的num[nCount] = %d\n",num[nCount]); //printf("这里的nCount = %d\n",nCount); if (nCount >= nLen) break; } fclose(fp); }