Logo 
Search:

C Programming Forum

Ask Question   UnAnswered
Home » Forum » C Programming       RSS Feeds

program codes

  Asked By: Elizabeth    Date: Jul 13    Category: C Programming    Views: 1569
  

How do i write a program in C that will update a text file.

Share: 

 

1 Answer Found

 
Answer #1    Answered By: Abhishek Singh     Answered On: May 13


/character by charecter adding./

#include<conio.h>
void add()
{
FILE *p;
p=fopen("asd.txt","a");
char c;
c=gatchar();
while(c!=EOF)
{
fputc(c,p);
c=getchar();
}
fclose(p);
}
void main()
{
FILE *p;
add();
p=fopen("asd.txt","w+");
c=fgetc(p);
while(!feof(p))
{
printf("%c",c);
c=fgetc(p);
}
fclose(p);
getch();
}

 
Didn't find what you were looking for? Find more on program codes Or get search suggestion and latest updates.




Tagged: