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();
}
#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();
}
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.