Wednesday, November 23, 2011

How to enter the data into a file and then copy into another file ????


Here i am posting a program which writes the data which you have entered into ganesh through console and copies that data particular data into another file .



#include<stdio.h>
void main()
{
FILE *f1, *f2;
char ch;
f1 = fopen("Ganesh.txt","w+");
f2 = fopen("Simple.txt","w");
printf("Enter data into ganesh file (ctrl+z to stop) : ");
while((ch=getchar())!=EOF)
putc(ch, f1);
rewind(f1);
while((ch=getc(f1))!=EOF)
putc(ch, f2);
printf("\n\t\tData copied from ganesh to simple file");
fclose(f1);
fclose(f2);
getch();
}

0 comments:

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Vamshi krishnam raju | Bloggerized by Vamshi krishnam raju - Vamshi krishnam raju | Vamshi krishnam raju