Question:
HOW TO READ TEXT FILE AND READ IT INTO ANOTHER TEXT FILE?
Answer:
It can be done using get() & write() functions. Source: CoolInterview.com
Answered by: Gaurav Samantaray | Date: 8/22/2008
| Contact Gaurav Samantaray
first open the file in a+ mode and read the data using gets(),getc() or fscanf(),<br>then rewind the file and and by using putc(),puts(),fprintf() wecan write them to another file Source: CoolInterview.com
Answered by: amul | Date: 8/27/2008
| Contact amul
#include <iostream><br>#include <conio.h><br>using namespace std;<br>void main()<br>{<br> char c;<br> FILE *fin,*fout;<br> fin=fopen("min.txt","rt");<br>if(fin==NULL)<br> {<br> cout << "Error";<br> getch();<br> return;<br> }<br> /* while((c=fgetc(fin))!=EOF)<br> cout << c;*/<br> fout=fopen("mout.txt","wt");<br> if(fout==NULL)<br> {<br> cout << "Error";<br> getch();<br> return;<br> }<br> while((c=fgetc(fin))!=EOF)<br> fputc(c,fout);<br> getch();<br>} Source: CoolInterview.com
Answered by: Giani | Date: 9/15/2008
| Contact Giani
If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
- There should not be any Spelling Mistakes.
- There should not be any Gramatical Errors.
- Answers must not contain any bad words.
- Answers should not be the repeat of same answer, already approved.
- Answer should be complete in itself.
|