dev-cpp premature closing

c, c++, php, html, sql ..etc discussion. also includes codes and source codes.
Post Reply
PinPoint
Special
Special
Posts: 126
Joined: Wed Dec 03, 2008 6:41 pm

dev-cpp premature closing

Post by PinPoint »

ive started learning c++ and came across this problem which i got over:)

using a c++ tutorial doing exactly as said didnt let you see the results in dev-cpp, the window flashed then closed right away.

original(window closing code)

Code: Select all

#include <iostream.h>

int main()
{
     cout << "Hello world\n";
          return 0;
}
this code just made the exe flash after it being compiled and linked. but i found out how to fix it.
use

Code: Select all

#include <cstdio> and getchar()
in the source as shown here...

Code: Select all

#include <cstdio>
#include <iostream.h>

int main()
{
     cout << "Hello world\n";
          getchar();
          return 0;
}
now the window will stay open untill you close it.

for anyone who has the same problem while learning


NOTE: I know that <iostream.h> is outdated and is just <iostream> now but still works with dev-cpp and this is what the tutorial is saying so im going with what it is saying for now.
User avatar
Sethioz
Admin
Admin
Posts: 4762
Joined: Fri Jul 27, 2007 5:11 pm
Custom: Gaming YT > https://youtube.com/SethiozEntertainment
Game Hacking YT > https://youtube.com/sethioz
Game Hacks Store > https://sethioz.com/shopz
Location: unknown
Contact:

Re: dev-cpp premature closing

Post by Sethioz »

im using mingw compiler, one that Luigi suggested. never used any of this
however if you have problems, ask Luigi :) he knows C inside out.
wolfguardiann
User
User
Posts: 31
Joined: Fri Nov 26, 2010 2:21 pm

Re: dev-cpp premature closing

Post by wolfguardiann »

this problem is cuz u didnt used the

Code: Select all

system("pause");
delete this

Code: Select all

return = 0 
return 0
cuz if sucess it will close , so , dont use that , :)
Post Reply