23,120
社区成员
发帖
与我相关
我的任务
分享
[root@RHEL6A ccode]# cat readfile.c
#include <stdio.h>
int ReadIniFile(char* strFile);
int main(int argc, char* argv[])
{
int iRet;
iRet=readfile("/tmp/msisdn.txt");
}
int readfile(char* strFile)
{
FILE *fp;
char cLineBuffer[100];
fp=fopen(strFile,"r");
if(fp == NULL)
{
printf("can not open the config file %s",strFile);
return -1;
}
while(fgets(cLineBuffer,100,fp)!=(char *) NULL)
{
printf("%s",cLineBuffer);
}
fclose(fp);
return 0;
}
[root@RHEL6A ccode]# cat /tmp/msisdn.txt
2001
2002
2003
[root@RHEL6A ccode]# gcc -o readfile.o readfile.c
[root@RHEL6A ccode]# ./readfile.o
2001
2002
2003