online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code   
Language
//Listing 14.08 Using Command-line Arguments #include <fstream> #include <iostream> #include <cassert> // assert() using namespace std; typedef struct { int x; int y; } Vector; int main(int argc, char *argv[]) // returns 1 on error { if (argc != 2) { cout << "Usage: " << argv[0] << " <filename>" << endl; return(1); } ofstream fout(argv[1], ios::binary); assert( fout.is_open() ); // and check for success Vector v = {5,12}; fout.write(reinterpret_cast<char*>(&v), sizeof v); fout.close(); ifstream fin(argv[1], ios::binary); // establish connection, assert( fin.is_open() ); // and check for success Vector v2 = {3,4}; cout << "v2.x\t:\t" << v2.x << endl; cout << "v2.y\t:\t" << v2.y << endl; fin.read(reinterpret_cast<char*>(&v2), sizeof v2); cout << "v2.x\t:\t" << v2.x << endl; cout << "v2.y\t:\t" << v2.y << endl; fin.close(); 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