Problem
Write a C program to open any C source file and displays its content on console. Use fgetc function.Solution - Code
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
#include<string.h>
int main ()
{
FILE *fp;
char ch;
fp = fopen ("p2.txt","r");
while (1)
{
ch = fgetc(fp);
if ( ch == EOF )
break;
printf ("%c",ch);
}
fclose (fp);
system ("pause");
return 0;
}
No comments :
Post a Comment
Note: Only a member of this blog may post a comment.