I just moved from Windows to Linux and I'm try to create a simple application that opens a console, displays a message and wait for key press to close. I have created it on Windows and it works, then I just moved the files to Linux. Didn't make any change, just compiled it with g++ and I get no errors. The problem is that on Linux (Ubuntu 12.04) I can't see the console and some message asking 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;
}
On Windows, when I start the executable, the console windows will show me the messages and close when pressing any key. On Linux, when I execute the program I don't get anything. It does create the testfile.txt file and insert the text, so cstdio related functions does work, but I can't see any console with those messages and I don't understand why. Maybe I don't know how to open a simple executable on Linux. What I want is to double click on it and see a console with two simple messages. What do you thin I'm doing wrong? Thanks!
Also, I use g++ to compile the cpp file: g++ -Wall -s -O2 test.cpp -o test