-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfgets.c
41 lines (34 loc) · 796 Bytes
/
fgets.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*===============================================================
* 文件名称:fgets.c
* 创建日期:2016年08月03日
================================================================*/
#include <stdio.h>
int main()
{
FILE *fp = NULL;
fp = fopen("/tmp/route_ipv4.log", "r");
if(NULL == fp)
{
printf("call fopen error!\n");
return -1;
}
int lineNum = 0;
while(!feof(fp))
{
//if(0x2 > lineNum)
//{
// lineNum ++;
// continue;
//}
char line[1024] = {0};
if(NULL == fgets(line, 1024, fp));
{
printf("call fgets error!\n");
// fclose(fp);
// return -1;
}
printf("%s\n", line);
}
fclose(fp);
return 0;
}