when click on .exe(console app) it flashes away

after compiling in release mode when i click on .exe it flashes away when i debug it in ide(vs 2010) it stays. what can i do so it should stay & not flashed away.

ty for the reply, i am completely a beginner, learning c++ on my own it has been only 5 days.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <conio.h>
#include <stdio.h>

void PressAKeyToContinue()
  {
  int c;
  printf( "\nPress a key to continue..." );
  c = getch();
  if (c == 0 || c == 224) getch();
  }

int main()
  {
  puts( "Hello world!" );
  PressAKeyToContinue();
  return 0;
  }

this "pressanykeytocountinue" function ,how can i include it in conio.h as another function? please tell me in steps sorry for asking you to me through.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <string>
#include <iostream>
using namespace std;

void Wait()
{
	cout << "Press Enter to Continue.\n";

	cin.ignore(1,'\n');

	cout << "\n";
	
}

1
2
// PROTOTYPES
void Wait();


and just call Wait(); or whatever you name your function
Last edited on
to avoid every time to write it how can i permanently put it in a obj file?
please explain the procedure to do it
you can either do that

or download std_lib_facilities.h

and use the keep_window_open(); function in your main.cpp

but i have the above code in a seperate cpp file called helper.cpp

and then i created a globals.h

inside there

1
2
3
4
5
6
7
8
9
10
11
12

#ifndef GLOBAL_DEFINE
#define GLOBAL_DEFINE


// PROTOTYPES
void Wait();
//bool Junction();
//bool Village(PLAYER*);
//bool Portal(PLAYER*);
#endif


then #include "Globals.h" in your main.cpp
ignore the stuff commented out

you still have to put Wait(); in your main too
Last edited on
Topic archived. No new replies allowed.