#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);
}

















![[3/11]C#性能优化-实现 IDisposable 接口-每个细节都有示例代码](https://i-blog.csdnimg.cn/direct/1a7b3920793a4d9b9801c5d85065ca50.png#pic_center)

