Question:
need help in c++ while executing...?
anonymous
2006-09-02 07:24:53 UTC
hi guys...
i need help in executing a program i made in c++...
i compile it in my compiler and 0 errors/warnings show up, but when i try to execute it, it appears for a second and then disappears!!! please help! thanks in advance
Six answers:
anonymous
2006-09-02 08:49:29 UTC
Okay, without a clue about the platform or compiler you're using, here is a bit of guess that may work. Try '#include ' as your included header file. The C++ standard on ANSI headers and their inclusion names are different. Use getch(), not getche(). If this doesn't work, look through the documentation you have with the compiler and find an input routine that gets one character from standard input (stdin) and returns it. Use that if the above didn't work. Another, though non-portable, option in Windows/DOS/Linux would be the line 'system("pause");'. Now a word on placement of any of the above lines. They should appear inside the main function just before the return statement that is the last statement in that function. Example below:



int main(void) //Doesn't have to be declared exactly like this.

{

//Do your programatic thing here.

//getch(); or other_function(); or system("pause"); goes here.

getch();

return(0); // Could be return SOMETHING; or other return.

}



I hope that this gets you what you want. You can also use the run command to run your executable file and the window will stay open.
cz
2006-09-02 07:29:22 UTC
The program executes just fine, its just that the computer executes it so fast, you dont have time to see the output.

Add the command getche() to your code to pause it until you press a key



Hope that helps!
R N
2006-09-02 07:27:43 UTC
hi!!!

yeah the computer is very fast and it will return back to the editor once the execution is finished.. you can pause the execution of the program so as to see the result by using



getch()



function present in the conio.h header file( include conio.h in your program)
alakit013
2006-09-02 07:58:37 UTC
1. Execute it from console so you will see output after program is terminated.

2. Wait before return:

#include

#include

inline void wait(void) { wile( !kbhit() ) ; getch(); }

...

atexit( wait );

...
Arun M
2006-09-02 07:28:20 UTC
U should specify that what is appear and what is desappear. r u saying about command promet or other.



would U send me the code which U r compiling?



Thanks
crooker
2016-11-24 00:05:56 UTC
incorporate iostream #incorporate string ... ... cout<<"Please enter record call"; string filename; cin >> filename; ifstream myfile (filename); string line; if (myfile.is_open()) { on a similar time as (! myfile.eof() ) { getline (myfile,line); if(strcmp(line, "pop") == 0) { // Pop from the stack } else { // split line to acquire what you're pushing to the stack. // Push it to the stack. } } myfile.close(); } else cout << "unable to open record";


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...