100% C prog to append content to existing file and then read the whole content
#include<stdio.h>
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
fptr=fopen("kotta1601.txt","a");
printf("\n start entering the data: \n ");
ch=getchar();
while(ch!='z')
{
fputc(ch,fptr);
ch=getchar();
}
fclose(fptr);
printf("\n appending completed");
printf("\n start reading the data from the file: \n ");
fptr=fopen("kotta1601.txt","r");
while(!feof(fptr))
{
ch=fgetc(fptr);
putchar(ch);
}
fclose(fptr);
getch();
}
#include<conio.h>
void main()
{
char ch;
FILE *fptr;
fptr=fopen("kotta1601.txt","a");
printf("\n start entering the data: \n ");
ch=getchar();
while(ch!='z')
{
fputc(ch,fptr);
ch=getchar();
}
fclose(fptr);
printf("\n appending completed");
printf("\n start reading the data from the file: \n ");
fptr=fopen("kotta1601.txt","r");
while(!feof(fptr))
{
ch=fgetc(fptr);
putchar(ch);
}
fclose(fptr);
getch();
}
కామెంట్లు
కామెంట్ను పోస్ట్ చేయండి
దయచేసి మీ సలహాలను సూచనలను స్పష్టంగా పేర్కొనగలరు. plz see that ur comments are 'acceptable' in a value based society.