Pages

Friday, March 24, 2017

Program to read and print test.txt file.

This C program will read content from a test.txt file and print it on a screen.

#include<stdio.h>
int main(){

 FILE *fp, *fopen();
 char str1[80], ch;

 fp = fopen("test.txt","r");
 ch = fgetc(fp);

 while(ch != EOF)
 {
  printf("%c",ch);  
  ch=fgetc(fp);
 }
 fclose(fp);
 return 0;
}

Output of the program

Hello Student,
This content is from test.txt file.

No comments:

Post a Comment