int sread[20];
char buf[1024]; /*缓冲区*/
FILE *fp; /*文件指针*/
int len; /*行字符个数*/
int z=0;
if((fp = fopen("test.txt","r")) == NULL)
{
perror("fail to read");
exit (1) ;
}
while(fgets(buf,MAX_LINE,fp) != NULL)
{
len = strlen(buf);
buf[len-1] = '\0'; /*去掉换行符*/
printf("%s %d \n",buf,len - 1);
//int kread=atoi(buf);
sread[z]=atoi(buf);
printf("data:%d \n",sread[z]);
z++;
}