cout does not execute

Pages: 12
Now, this might be a stupid error, but I can't figure it out.
I just started learning C++, and I am currently following this tutorial: http://www.cplusplus.com/doc/tutorial/program_structure/

However, after building the project, cout doesn not execute and the program does not end.

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>

using namespace std;

/*
 * 
 */
int main(int argc, char** argv) {

    cout << "Hello World";
    return 0;
}


Output (After I manually stop the build):
RUN FAILED (exit value -2,147,483,648, total time: 363337h 22m 17s)


Using:
Windows 7 32bit
MSYS and MinGW
Netbeans
It worked fine for me; must be NetBeans.
And you let it run for 41 years? Talk about patience.

I see no reason why this would not work properly.
closed account (yUq2Nwbp)
Boreeas it could be from how you open window where you write your code......there is one case where you must input this in your code

#include<stdafx.h>

try it....
stdafx.h is generated by VS and the OP is running NetBeans so that won't work.
closed account (yUq2Nwbp)
ascii there is one way to open window, where you must input that stdafx.......i used to open window in that way and then i had to include stdafx...
closed account (zb0S216C)
david91 wrote:
there is one way to open window, where you must input that stdafx
Stdafx is a VC++ generated header. I always remove Stdafx from all of my projects, and yet, my projects compile just fine. The Stdafx header is not a requirement.

Wazzak
Last edited on
closed account (yUq2Nwbp)
Framework i don't say there is only way to open window i say i know way opening window, where include<stdafx.h> is necessary......if you want i could tell you that way.....ok?
netbeans is for java, isn't it?

@helios: wahahaha...
david91, as both me and framework have pointed out it's a VC++ generated header so it isn't going to help the Boreeas, because he is using NetBeans.

@chipp, it is mainly for Java but it supports C/++ as well, though I don't see why anyone would develop in it as opposed to the countless other and "better" C/++ IDE's out there.
ascii wrote:
I don't see why anyone would develop in it as opposed to the countless other and "better" C/++ IDE's out there
@O.P: You might benefit from changing IDE's as ascii suggested.

I use Visual Studio 2008, which is a premium IDE, but you can find the cut down "Express" version for C++ in the link below:

http://www.microsoft.com/express/Downloads/

It might be a bit bulky to use at first but there are a lot of handy features in it that have become indisposable for me (I am not a sales rep from Microsoft ;) ).

As for your code, it should work which leads me to believe that it's probably your IDE.

I hope this helps!

P.S: If your a student, it might be worth your while to check with your school to see if they have a software licensing agreement with Microsoft (the program is called the MSDN Academic Alliance), which entities you to free software not limited to Visual Studio 2008/2010.
Last edited on
I would also blame some sort of poor NetBeans/compiler configuration, but without any further details I won't be able to pinpoint it.

Maybe try reinstalling everything? *shrug*

Finally, in my experience Netbeans is actually a pretty decent IDE. Its code completion glitches at times and its C++0x support is iffy, but at least it runs properly when it's on OS X (I've had major issues with C::B).

-Albatross
closed account (yUq2Nwbp)
ascii do you want me to mention the way opening window that i have said ??:)
When I rarely do Java NetBeans can be nice, but I still think that Visual C++ 2008 is much better for C++ development. david91, go ahead in another thread, I'm just saying that it isn't relevant to the OP because stdafx.h is generated by Visual Studio and it won't work in NetBeans.
closed account (yUq2Nwbp)
i understood..........but lets be polite to each other...ok???
It's your IDE, netbeans isnt really a good compiler for C++, it's more java oriented.

Try VC++ or CodeBlocks.
Sorry for the late reply. Yeah, I installed Visual Studio now, and it works fine. Thanks for your help!

Edit: Actually, I still have one problem:
1
2
3
string agePrompt = "Enter your age!";

cout << agePrompt << endl;


Gives me an error at the first "<<": "Error: no operator ("<<") matches these operands.
Last edited on
lnk2019 wrote:
P.S: If your a student, it might be worth your while to check with your school to see if they have a software licensing agreement with Microsoft (the program is called the MSDN Academic Alliance), which entities you to free software not limited to Visual Studio 2008/2010.


Yup, got Windows 7 Professional for free from them :)
closed account (zb0S216C)
Boreeas wrote:
Gives me an error at the first "<<": "Error: no operator ("<<") matches these operands.

Call c_str( ) from agePrompt.

Wazzak
Thanks for your help!


dose that mean that this is solved?
Pages: 12