I wrote a simple program to print out Testscore in Visual Studio .Net 2003
and got the following messages when trying to run it.

'TestScore.exe': Loaded 'D:\Documents and Settings\pooleb\My Documents\Visual Studio Projects\TestScore\Debug\TestScore.exe', Symbols loaded.
'TestScore.exe': Loaded 'D:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'TestScore.exe': Loaded 'D:\WINDOWS\system32\kernel32.dll', No symbols loaded.
The program '[3920] TestScore.exe: Native' has exited with code 0 (0x0).

This is the program:

#include <iostream>
using namespace std;
int main(void)
{
    short testScore;
        testScore = 3;
        cout << "Your test score is " << testScore << "\n";
        return 0;
}

It is from an example in C++ Demystified by Jeff Kent.

Am I doing something wrong?

Thanks, BandM

Dani AI

Generated

This is not a runtime error — it’s just the debugger telling you what it did and your program finishing immediately. The lines like “Loaded … ntdll.dll, No symbols loaded” simply report which modules the debugger saw; system DLLs normally don’t have debug symbols loaded and that’s fine. “Exited with code 0 (0x0)” means your program returned 0 (success). As said, the program ran and then the console closed in the blink of an eye.

Ways to see the output (without changing the program):

  • Run with “Start Without Debugging” (Ctrl+F5) in Visual Studio — the IDE will leave the console open and display a “press any key to continue” prompt.
  • Run the compiled EXE from a Windows command prompt (open cmd, cd to the Debug folder, type the EXE name).
  • If you want to debug and inspect state, set a breakpoint before the program exits and step through. ’s point about avoiding shell calls is worth noting: calling the shell to pause is platform-dependent; prefer a simple, standard C++ input wait or a breakpoint.

If paste-from-webpage code gives build errors, common causes are smart quotes or other non-ASCII characters, HTML entities for angle brackets, wrong file extension, or a missing header/namespace. Paste into a plain-text editor first (Notepad) to strip formatting, save as .cpp, and ensure you created a Console project. If errors remain, post the exact error text and the snippet that fails.

A minimal, portable way to pause for input (so you can see output) is to wait for input at the end of main, for example with std::cin.get(); — or simply use Ctrl+F5 while developing.

Recommended Answers

All 8 Replies

If you want to see the result, you could do the following :

add

#include <stdlib.h>

before the first line of your program

add

system("pause");

before the end of your main() function.

include the header file --> #include <stdlib.h>

then add this --> system("pause");
before the return 0;


*It causes the program to stop until it detects any keypress...

Yes, but as prog-bman said, (all my apologies :o ), this is not very smart, as using system("something") calls the external program something.exe.

using getchar(); is in fact much more portable between different systems

Is this something to do with studio .Net? because in VS 6.0 it doesn't do this.

I think VS 6.0 automatically places a pause after your program has executed.

Thanx All!

Your suggestions worked :p

I do want to know why, when I cut and paste one of the Cplusplus snippets
here and paste it into my editor and try to build it I get an error.
I am just starting out so, please be patient.

Thanx, BandM

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.