Tagged: program read file

C programming read text from a file and display it on screen 1

Program to read text from a file and display it on screen

We will write a program in C that will read a text file character by character and displays it on the screen. In order to achieve it, we will use fopen function that will open the file from the disk. We will also use fgetc function which will read the file character by character and then display the content of the string character by character. #include<stdio.h> #include<conio.h> void main() { FILE *fp; char ch; fp = fopen(“file1.C”,”r”); while(1) { ch = fgetc(fp); if (ch == EOF) break; printf(“%c”, ch); } getch(); fclose(fp); } C Programming is brought you by LearnCOnline.com

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet