Hey guys I did the following code and it still would not work
I dont get why this won't work. What do I do?Code:#include <iostream> int main() { std::cout<<"Hello World!"; return 0; }
Hey guys I did the following code and it still would not work
I dont get why this won't work. What do I do?Code:#include <iostream> int main() { std::cout<<"Hello World!"; return 0; }
The code seems good. What compiler are you using?
Hello, everyone.
> What do I do?
Well a better description than "doesn't work" would help for a start.
Like
- which operating system you're using
- which compiler you're using
- does it compile, if not, what error message(s) do you get
- does it run, if so, what do you see (or not see) compared to what you expected to happen.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
I think it works its just that it closes before you can see it
http://faq.cprogramming.com/cgi-bin/...&id=1043284385Code:#include <iostream> int main() { std::cout << "Hello World!"; system("PAUSE"); // this pauses the program before it exits return 0; }
more ways there
I'm using Microsoft Windows XP Professional. I'm using Microsoft VIsual C++ 6.0 Professional also. I got it to work however by doing using namespace std; below the inclusion of the header file and using simple cout<< without the std:: in front of it. For some reason my compiler doesn't like the std:: very much. Thanks for the help guys. I'll have some questions on object oriented programming soon.
Herns
Update your VC6 with SP5, and it will like std:: very much also.
Hello, everyone.
Try including a newline '\n' character in the string in case the output is line buffered.
No. A \n doesn't flush the buffer; don't use it with cout. Instead, use this:Originally Posted by ^xor
However, the buffer will be flushed automagically when the program exits anyway, so it wouldn't be a concern in this program as far as it not working. (The buffer also flushes automagically when it's full or the operating system decides to flush it.)Code:cout<<"Hello world!"<<endl;
Away.
> No. A \n doesn't flush the buffer; don't use it with cout. Instead, use this:
stdout output is line buffered by default if the text is sent to a terminal.