Reputation: 1
I know this is probably a dumb question but I am a beginner and I just started learning today. I am using Dev C++ and I wrote my first code:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World" ;
return 0;
}
I click to compile and run. Nothing comes up. Then I click just "run" and it said it is not compiled yet.
I think there might be errors and I would have gladly fixed them myself but I don't know where I can see the errors in Dev C++.
Could this be a compiler error or did I mess up something in my code?
Thanks!
Upvotes: 0
Views: 115
Reputation: 726479
Most likely your program exits before it manages to write everything out to the console. Try adding new line to the output, like this:
cout << "Hello World" << endl;
When you write to cout
, the data is not transfered to the screen right away, out of efficiency considerations. Writing to the screen is relatively slow, so the program prefers to do it in "bursts". The text is accumulated in a buffer until a special command is given to flush the buffer, or the buffer fills up. Writing out endl
forces a flush, so the output will appear on the screen before your program exits.
Upvotes: 1