spectre-d spectre-d - 1 month ago 5x
C++ Question

VC++ and *nix Compiler Differences

So, just started Programming I at college; unfortunately, this:

Submissions must be a notepad *.txt file in xx pt fixed width font


That's besides the point though! So it is "required" (I haven't received a confirmation email on whether or not *nix is fine, so long as it works in Windows) to use VC++, which seems ridiculously unnecessary for:

#include <iostream>

int main()
std::cout << "Hello, world." << endl;


return 0;

Besides the fact that I can't stand developing in a Windows environment, and prefer *nix machines...

My question is whether or not the following code will compile correctly in Windows, specifically
in an attempt to duplicate

#include <iostream>
#include <string>

using namespace std;

int main()
string p;

cout << "Hello, world" << endl;
cout << "Press enter...";
getline(cin, p);

return 0;

Are there any major differences between VC++ and *nix compilers that would affect the results of simple programs executing?

I've searched the web, and haven't found much of an answer.


Answering specific question as asked: Yes, std::getline(std::cin, p) will suspend execution until the \n character is read from the std::cin. This assumes there is no such character before the prompt is displayed - for example, simply because user already pressed it.