Dev C++

Started by
8 comments, last by ookooa 19 years, 8 months ago
is there any kind of hack or something I can use to keep the console window open other than adding code like system("PAUSE") and the like? I just find it annoying :(. I know at school somehow they got it to work (although it was a different compiler)
Sidra Headquarters
Game engine is currently at version 0.9.8! Currently Down
Advertisement
system("pause");

char x; std::cin >> x;

getch();

...they're all really hacks though, the correct way to do it is to open a console and run it in the console.
Ra
well like I know how to keep it open buy those means, I was just hoping that there was some compiler command or something. oh well heh

EDIT: fixed my terrible typing :D
Sidra Headquarters
Game engine is currently at version 0.9.8! Currently Down
If you're running Windows, try this:

#include <windows.h>int main(int argg, char *argv[]){  ...  while(!GetAsyncKeyState(VK_ESAPE)  {    // Will exit loop when escape-key is pressed  }  return 0;}
Open a console window (Start->Run... 'cmd') and run your program from there.
Quote:Original post by JoHnOnIzEr
is there any kind of hack or something I can use to keep the console window open other than adding code like system("PAUSE") and the like? I just find it annoying :(. I know at school somehow they got it to work (although it was a different compiler)

could this different compiler possibly be Visual C++? because Visual C++ inserts the code to leave it open i believe.
Hm.. Many IDEs contain launcher app, that wait, after your program has ended.

But, I think, that some quick batch file hack would be sufficent:

yourprogram.exepause


Save it as .bat and run this instead of your exe.

Oxyd
Put a breakpoint before the program returns, then run in debug mode.
ok I'm new to C but i have done some pascal and basic and in turbo pascal inserting a readln statement at the end of your program stopped the console from closing and waited for some keyboard input before closing the console. i believe below is the C equivilant as it worked for me but i am new and i may be wrong. Below is a simple example program using this method.
============================================================
#include <stdio.h>

main()
{
int dummy;
printf ("hey is it working?");
dummy = getchar();
return 0;
}
=============================================================
the program waits at line 7 to get a value for dummy from the keyboard, just hit enter and the console closes.
You are best jut to add cin.get(); before return 0; your going to have to use it anyway.

This topic is closed to new replies.

Advertisement