with the help of pointer this program shows to open abc.txt
file using file program in c
#include<stdio.h> // HEADER FILES//
#include<conio.h>
main() //main start//
{
FILE * fp;
char ch;
clrscr();
fp=fopen("abc.txt","r");
if(fp==NULL) //if file is null//
{
printf("error");
getch();
}
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
printf("%c",ch);
}
fclose(fp);
getch();
}
file using file program in c
#include<stdio.h> // HEADER FILES//
#include<conio.h>
main() //main start//
{
FILE * fp;
char ch;
clrscr();
fp=fopen("abc.txt","r");
if(fp==NULL) //if file is null//
{
printf("error");
getch();
}
while(1)
{
ch=fgetc(fp);
if(ch==EOF)
break;
printf("%c",ch);
}
fclose(fp);
getch();
}
0 comments: