Jun 18, 2008 at 2:33pm UTC
hi i am new to c++ and i just installed it yesterday but i did not get much time to use it.i just put a hello world program in it with dev c++ but once i started it, it closed very fast. this is probaly a noob problem but thanks anyways
#include <iostream>
using namespace std;
int main ()
{
cout << "Hello World!";
return 0;
}
Jun 18, 2008 at 2:48pm UTC
try to put this at the end:
I use this in my console apps.
Or try to start your app from Command Promt
Last edited on Jun 18, 2008 at 2:50pm UTC
Jun 18, 2008 at 2:50pm UTC
i put it before the return 0; and it did not work, did you mean for me to put it somewhere else?
Jun 18, 2008 at 4:46pm UTC
dear sir,
kindly try this
#include <iostream>
#include<conio>
void main ()
{
cout << "Hello World!";
getch();
}
regards
matanuragi
Jun 18, 2008 at 5:11pm UTC
no it did not work but thank you anyways
Jun 18, 2008 at 5:30pm UTC
i found something that works
Jun 18, 2008 at 6:12pm UTC
<conio.h>
is a library that is only included in a Borland compiler. Try:
1 2 3 4 5 6 7 8 9 10
#include <iostream>
using namespace std;
int main ()
{
cout << "HELLO WORLD!! " ;
cout << "Press ENTER to continue...\n" ;
cin.get();
return 0;
}
Last edited on Jun 19, 2008 at 2:35pm UTC
Jun 18, 2008 at 8:08pm UTC
If you're on windows, you can use a nice little system("pause"); command.
Not really portable though.
Jun 29, 2008 at 7:54am UTC
dear sir,
kindly try this
#include <iostream>
#include<conio>
using namespace std;
int main ()
{
cout << "Hello World!";
getch():
return 0;
}
with regards,
matanuragi
Jun 29, 2008 at 11:00am UTC
@matanuragi
No one here is so stupid that you have to repeat yourself. <conio.h> is a non-portable library in any case.
@alexcook
There is a thread at the top of this forum entitled Console Closing Down . It deals specifically with your problem.
Good luck.