Write a C program to display the contents of a file.

Program Code:
#include<stdio.h>
void main()
{
FILE *fp;
char ch;
fp=fopen("file.txt","r");
if(fp==NULL)
{
printf("file opening problem");
return;
}
while(!feof(fp))
{
ch=fgetc(fp);
printf("%c",ch);
}
fclose(fp);
}
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: