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
project on business management

array of class objects and single inheritance

Explain the terms- Substitutability and Extensibility Substitutability - The objects of a properly derived class can be safely and easily substituted for an object of its

THIS PROGRAM IS TO MULTIPLY THE TWO COMPLEX NO.S GIVEN BY THE USER #include #include #include struct complex     {     int real;     int imag;     }; void main()  {  clrs

Array of Objects: The objects can be declared just like a structure or even a primary data type.  Array of objects may be required to work with large set of data.   When the da

Can I explicitly call a destructor if I've allocated my object with new?

draw the flow chart to print the fibonacci series upto n th terms

Many human diseases could be controlled by the knowledge of the gene’s structure and pattern. The human gene could be represented by four nucleotides. Each nucleotide is represente

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

The voltage at the terminals of a battery is 52V when no load is linked and 48.8V when a load taking 80A is connected. Find the internal resistance of the battery. What wou