I just switched from Windows to Linux, and I'm trying to create a simple application that opens a console, displays a message, and waits for a key to close. I created it on Windows and it works, then I just moved the files to Linux. Did not make any changes, just compiled it with g ++, and I did not get any errors. The problem is that on Linux (Ubuntu 12.04) I do not see the console, and some messages ask me to press any key before closing. My code is as simple as this:
#include <iostream>
#include <cstdio>
int main() {
cout << "Writing file...\n";
FILE *myfile = fopen("testfile.txt", "w");
fwrite("test", sizeof(char), 4, myfile);
fclose(myfile);
cout << "Press any key to exit...\n";
cin.ignore();
return 0;
}
Windows, , . Linux, , . testfile.txt , cstdio , , , . , , Linux. , . , ? !
, g++ cpp: g++ -Wall -s -O2 test.cpp -o test