Pages

Monday, January 25, 2016

C program to read one line from a file.

This program will read and print one line from a "test.txt" file.   

#include<stdio.h>
int main(){
 
 FILE *f1, *fopen();
 char str1[80];
 
 f1 = fopen("test.txt","r");
 //Following line will read one line from a text.txt file. 
 fgets(str1,80,f1);
 puts(str1);  

 fclose(f1);
 return 0;
}

No comments:

Post a Comment