0

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 .

Bibi Tahira
  • 1,082
  • 5
  • 15
  • 39

3 Answers3

1
#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().

Ayrx
  • 2,092
  • 5
  • 26
  • 34
0

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.

Luchian Grigore
  • 253,575
  • 64
  • 457
  • 625
0

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.

Mohammad Dehghan
  • 17,853
  • 3
  • 55
  • 72