Write a program to display contents of file “a.txt” on the screen.
C File =>
Note : First create a.txt file and then write above c file
// Write a program to display contents of file “a.txt” on the screen.
#include<stdio.h>
#include<stdlib.h>
int main() {
FILE *fp;
char ch;
fp=fopen("a.txt","r");
if(!fp)
printf("\n Error in reading file");
else
{
while((ch=fgetc(fp))!=EOF)
printf("%c",ch);
}
return 0;
}
Note : First create a.txt file and then write above c file
Comments
Post a Comment
Please do not enter any spam link in message.