![](https://i-blog.csdnimg.cn/blog_migrate/09165b34bf94eab1e49f0bcd8e4f6bdb.png)
kettle 逐行读取文件
Here you will get C program to read file line by line.
在这里,您将获得C程序逐行读取文件。
In below program we first open a demo file hello.txt with some text in read mode. Make sure the file is already present. Then we read the file character by character and display on screen.
在下面的程序中,我们首先打开一个演示文件hello.txt,其中的某些文本处于读取模式。 确保文件已经存在。 然后,我们逐字符读取文件并显示在屏幕上。
程序 (Program)
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
char ch;
fp = fopen("hello.txt","r");
if(fp == NULL)
{
printf("File not found. \n");
}
else
{
printf("File is opening..... \n\n");
while((ch = fgetc(fp)) != EOF )
{
printf("%c", ch);
}
}
fclose(fp);
return 0;
}
Output
输出量
![C Program to Read File Line by Line](https://i-blog.csdnimg.cn/blog_migrate/f0d8855985768d880ecb34244d59fa44.png)
翻译自: https://www.thecrazyprogrammer.com/2018/08/c-program-to-read-file-line-by-line.html
kettle 逐行读取文件