100% C prog to write content into a file and then read it back onto the console

#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
// clrscr();
fptr=fopen("kotta1601.txt","w");
printf("\n start entering the data: \n ");
ch=getchar();
while(ch!='z')
{
fputc(ch,fptr);
ch=getchar();
}
fclose(fptr);
//writing file is completed now lets start reading from the just created file
fptr=fopen("kotta1601.txt","r");
printf("\n start reading the data from the file: \n ");
while(!feof(fptr))
{
ch=fgetc(fptr);
putchar(ch);
}
fclose(fptr);
getch();
}

కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

Assignment to gain eligibility to industry visit

Seniors assignment _ must for registration to attend workshop by TCS యశ్వంత్ జీ