online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
//Listing 14.02 Appending to the End of a File #include <fstream> // ifstream, ofstream #include <cassert> // assert() #include <iostream> using namespace std; int main() { char file_name[80] = ""; char buffer[255] = ""; char ch = ' '; cout << "Please reenter the file name: "; cin >> file_name; ifstream fin(file_name); // establish connection, assert( fin.is_open() ); // and check for success cout << "\n\nCurrent file contents:\n\n"; while (fin.get(ch)) cout << ch; cout << "\n***End of file contents.***\n\n"; fin.close(); cout << "Opening " << file_name << " in append mode...\n"; ofstream fout(file_name, ios::app); // establish connection, assert( fout.is_open() ); // and check for success cout << "\nEnter text for the file: "; cin.ignore(1,'\n'); cin.getline(buffer, 255); fout << buffer << "\n"; fout.close(); // close the connection // PARTE 2 fin.open(file_name); // reassign existing fin object! assert( fin.is_open() ); cout<<"\n\nHere's the contents of the file:\n\n"; while( fin.get(ch) ) cout << ch; cout<<"\n***End of file contents.***\n"; fin.close(); // close the connection return 0; }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue