HELP - Win32 wont let me run my c++ :(

i have recently been bought a book on c++ programming (learn c++ in 24 hours) and have been trying to make it work on serveral compilers no with no success. The compiler that came with the book is BorlandC++BuilderX and that seemed to work fine until i tryed to run the .exe. The Win32 (DOS) window flashed briefly and then closed again. i read up on this on several forums and decided to try Microsoft Visual C++ Express 2005, as this was meant for windows, and a couple of people seemed to think that my pc being an XP had something to do with it not working.

I created a new project in Visual C++ and just used the basic 'Hello World' program suggested for begginers. When i tried to debug it i was faced with:

'hello world.exe': Loaded 'C:\Documents and Settings\Luke\My Documents\Visual Studio 2005\Projects\hello world\debug\hello world.exe', Binary was not built with debug information.

'hello world.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.

'hello world.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.

'hello world.exe': Loaded 'C:\WINDOWS\system32\shimeng.dll', No symbols loaded.

'hello world.exe': Unloaded 'C:\WINDOWS\system32\shimeng.dll'

The program '[1264] hello world.exe: Native' has exited with code 0 (0x0).

Thanx.



Answer this question

HELP - Win32 wont let me run my c++ :(

  • Espen

    Thankyou so much, i'll try that. (and btw im pretty certain that its not express that does that *_-)

     

    EDIT: Sorry to sound like a total newb but, how exactly would i do this (build in some code so that it doesn't terminate automatically), i havn't really had any practice with C++, as my pc wont let me run the files...


  • bensterdev

    Hi, Luke.  I guess the good news is that I started with that book, and was working as a C++ developer 4 months later :-)

    Your friends who suggested that the probelm was XP, I recommend not asking them stuff in future, ask here instead :-)

    Your code is running fine, on both compilers.  The trouble is, the code does not contain anything to force it to stop what it's doing, so it comes to an end, and the program ends, the window closes.  I generally add a line like int ii = 0;, and press F9 on that line to add a breakpoint.  Then, the compiler will run to that line, and stop, going into debug mode so you can examine variables at that point of execution.  This also means that the app will still be visible in the console window.

    I believe with Express, the debug version actually inserts code to make you press a key before it closes.  At least, I believe one or the other does, and your output makes me think you're building a release version, hence I assume it's teh debug version that does this.  Of course, if you're building a release version, adding a breakpoint won't help ( to be honest, I thought it was the other way around, and I'm now leaving the above advice mostly to show you how to create breakpoints ).

    Good luck !!!

    P.S. - you should NEVER give your email address in a forum like this, it's an invitation for spam.  You should, however, set up your profile to use that address so you get an email when people reply to you here.



  • Dave Shaw

    In VC++ 2005 Express Edition, Ctrl+F5 (Debug | Start without debugging) will have the console window stay open until you can review the output and close the window when ready.

    In using the book you have chosen, you are developing console applications. If you run one directly in windows (by double-clicking the EXE or by using F5 in VC++ EE), a console window is created only for the duration of the application. If the application exits, the window goes away. So your program may be working, but it happens so fast that you don't get to see anything useful.

    The standard way to use console applications on their own is to start a "Command Prompt" session, go to where your compiled program is, and execute using a command line. When you are in a console session, the window stays open until you close it.

    You can get a little help about console sessions from XP by using Start | Help and Support. In the Help and Support Center window, enter "Using command prompt" in the Search field. This is skimpy material, but you can also type "help" at a command prompt and practice using commands like "cd" and "dir".

    It is possible to streamline the use of command prompts by making shortcuts that initiate console sessions in places where you want them. There are scripts (batch files, *.bat) that can be used to streamline further and to set parameters that have applications work better. You'll find that some organization of folders and VC++ projects will also make operation smoother.

    - orcmid

    PS: I have been sitting on some worked examples about creating and using console sessions for beginners with VC++ 2005 Express. I will begin posting those this weekend. This will make it easier to learn C and C++ using the many books that begin with development of console applications.



  • HELP - Win32 wont let me run my c++ :(