// C语言读取文件#include stdio.hint main() {FILE *fp;char buff[255];fp = fopen(/tmp/test.txt, r);
编程学习网为您整理以下代码实例,主要实现:C语言读取文件,希望可以帮到各位朋友。
// C语言读取文件
#include <stdio.h>
int main() {
file *fp;
char buff[255];
fp = fopen("/tmp/test.txt", "r");
fscanf(fp, "%s", buff);
printf("1 : %s\n", buff );
fgets(buff, 255, (file*)fp);
printf("2: %s\n", buff );
fgets(buff, 255, (file*)fp);
printf("3: %s\n", buff );
fclose(fp);
}