dev-cpp premature closing

c, c++, php, html, sql ..etc discussion. also includes codes and source codes.

dev-cpp premature closing

Postby PinPoint » Mon Nov 22, 2010 11:40 am

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
PinPoint
Special
Special
 
Posts: 128
Joined: Wed Dec 03, 2008 6:41 pm

Re: dev-cpp premature closing

Postby Sethioz » Mon Nov 22, 2010 6:20 pm

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.
User avatar
Sethioz
Admin
Admin
 
Posts: 4757
Joined: Fri Jul 27, 2007 5:11 pm
Location: unknown

Re: dev-cpp premature closing

Postby wolfguardiann » Thu Dec 16, 2010 3:26 pm

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 , :)
wolfguardiann
User
User
 
Posts: 31
Joined: Fri Nov 26, 2010 2:21 pm


Return to Programming / Coding / Debugging

Who is online

Users browsing this forum: No registered users and 1 guest