Bibi Tahira
Bibi Tahira

Reputation: 1082

C++ 1st program in visual studio 2008 express edition

i have write a basic code in c++

#include <iostream>
using namespace std;
void main()
{
    cout <<"its my programm";
}

when i compile it cmd line appear for a second and terminated noting was display. its was showing me this output in debug window.

'while.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll'
'while.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll'
'while.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcp90d.dll'
'while.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.vc90.debugcrt_1fc8b3b9a1e18e3b_9.0.30729.1_none_bb1f6aa1308c35eb\msvcr90d.dll'
The program '[1480] while.exe: Native' has exited with code 0 (0x0).

help me regarding this .

Upvotes: 0

Views: 1762

Answers (3)

Ayrx
Ayrx

Reputation: 2172

#include <iostream>
using namespace std
int main() {
    cout << "Hello World";
    cin.get();
    return 0;
}

This should work. The console exits before you can view the program. Using cin.get() will keep the program running until you press enter.

On a related note, your main() function really should be int and not void. I'm pretty sure some compilers do not allow void main().

Upvotes: 1

Moha Dehghan
Moha Dehghan

Reputation: 18472

Try this:

#include <iostream>
using namespace std;
void main()
{
    cout <<"its my programm";
    cin.get();
}

Then you must hit the Enter to close the console window.

Upvotes: 0

Luchian Grigore
Luchian Grigore

Reputation: 258638

That's because your console closes before you can see the output.

Try stepping through your program with F10. Or place a locking statement before the return.

Also, not that main should return int.

Upvotes: 0

Related Questions