Program to open a file in c++, C/C++ Programming

Program to Open a file in C++:

int main()

{

                 char ch;

                 ifstream f1 ("OLDFILE.TXT");

                 ofstream f2 ("NEWFILE.TXT");

 

                 if (!f1) cerr << "Cannot open OLDFILE.TXT for input";

                 if (!f2) cerr << "Cannot open NEWFILE.TXT for output";

 

                 while (f2 && f1.get(ch))

                                 f2.put(ch);

 

return 0;

 

}

Posted Date: 10/18/2012 9:23:40 AM | Location : United States







Related Discussions:- Program to open a file in c++, Assignment Help, Ask Question on Program to open a file in c++, Get Answer, Expert's Help, Program to open a file in c++ Discussions

Write discussion on Program to open a file in c++
Your posts are moderated
Related Questions
C Program for FUNCTION OF COUNT THE INTEREST float si(float,float,float); void main() {           float p=0,r=0,n=0,k=0;           clrscr();           printf("E

how to declare multi dimensional array

Is it possible to create your own header files? - Yes, it's possible to create a customized header file. - To do this, you just need to include function prototypes that you

Padovan String Problem Description A Padovan string P(n) for a natural number n is defined as: P(0) = ‘X’ P(1) = ‘Y’ P(2) = ‘Z’ P(n) = P(n-2) + P(n-3), n>2 where + denotes s

algorithm to prepare mark sheet of a student by inputing name,branchcode,semester,register no,5 marks of students and total mark of student

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin


At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Nec

Various ways of initializing the Arrays. - The for loop initializes 10 elements with the value of their index.      void main()     {                 const in