#include <stdio.h>
char *fgets(char *s, int size, FILE *stream);
使用fgets获取文件内容
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char str[100] = {0};
FILE *fp = NULL;
fp = fopen("./test_file", "r");
if (NULL == fp)
{
perror("fopen error");
exit(-1);
}
while (NULL != fgets(str, sizeof(str), fp))
{
printf("%s", str);
}
fclose(fp);
exit(0);
}