Reputation: 178
i write the simple hello program.
#include<iostream>
using namespace std;
int main()
{
cout<<"hello";
}
and I compile the program as g++ hello.cpp
and run it as./a.out
but could not get output as hello
Upvotes: 0
Views: 78
Reputation: 16945
You just didn't add a newline character. It worked, but you probably saw something like as follows where your normal prompt was:
hello$
If you change std::cout << "hello";
to std::cout << "hello\n";
, it'll "work" as expected.
Upvotes: 0
Reputation: 1244
The sample provide should work and should produce output. I do not see a reason not to print output. You could try flushing the std output stream and see whether it makes any difference. If you are running the program on a Linux platform, then you can debug using strace and there should be a write system call at the end.
strace a.out
Example: .... write(1, "hello", 5hello) = 5
exit_group(0) = ?
Upvotes: 1