Tuesday, November 27, 2012

Appending DATA to a Pre-Existing FILE using C languge


#include<stdio.h>

#include<conio.h>

#include<process.h>

void main()

{

FILE *f;

char c;

clrscr();

printf("\n contents of file before appending");

f=fopen("balaram.txt","r");

while(!feof(f))

{
 
c=fgetc(f);

 printf("%c",c);

}

f=fopen("balaram.txt","a");

if(f==NULL)

{

 printf("File can not appending");

  exit(1);

}

printf("\n Enter string to append:");

while(c!='.')

{
 
c=getche();

  fputc(c,f);

}

fclose(f);

printf("\n contents of file after appending:\n");

f=fopen("balaram.txt","r");

while(!feof(f))

{

  c=fgetc(f);

  printf("%c",c);

}

}

No comments:

Post a Comment

DC motor control with Pulse Width Modulation Part 1

DC Motor intro DC motor is a device which converts electrical energy into kinetic energy. It converts the DC power into movement. The typica...