Linux 底下使用C 对文件进行遍历

#include <stdio.h>
#include <stdlib.h>
main (int argc,char *argv[])
{
char ch;
FILE *fp;
int i;

if((fp=fopen("test.txt","r"))==NULL)
{
printf("Can not open the file:\n");
exit(0);
}

while((ch=fgetc(fp))!=EOF)
putchar(ch);
fclose(fp);

 

}

posted @ 2014-02-11 20:09  aspirant  阅读(200)  评论(0编辑  收藏  举报