| | |
why does it compile but not run?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 3,836
Reputation:
Solved Threads: 503
•
•
•
•
Using Dev-cpp, a small program compiles but the resultant .exe file
does not run. From the DOS command, it runs. When I try from the
windows run command , it flashes but immediately goes away.
C++ Syntax (Toggle Plain Text)
cin.ignore(); // this ignores one enter key
or
C++ Syntax (Toggle Plain Text)
system("pause"); // should use cin.ignore but you can use this // it displays: "Press any key to continue..." // and when you press any key, it continues...
or as veron was saying
C++ Syntax (Toggle Plain Text)
// Before using this make sure you have included: #include <windows.h> Sleep(1000); // the amount you put is in miliseconds, 1000 = 1 second // this will wait the amount of time you put into before moving on.
atm it is running correctly but it doesent know you want it to wait till you want to end it, so you have to add that.
Last edited by u8sand; Jan 4th, 2009 at 9:41 am.
•
•
Join Date: Nov 2007
Posts: 390
Reputation:
Solved Threads: 39
C++ Syntax (Toggle Plain Text)
cin.ignore(cin.rd_buf()->in_avail()); cin.get();
Slap that on the end of the code. This will do the following:
ignore all the available input from the cin (console) input buffer, then grabs a null terminated character (basically waits until you hit enter).
Last edited by skatamatic; Jan 6th, 2009 at 6:23 pm.
![]() |
Similar Threads
- visual c++ strange compile error... (C++)
- Will This Computer Run Windows Vista? (Windows Vista and Windows 7)
- how to compile and run java programs in fedora8 (IT Professionals' Lounge)
- Compile Java (Java)
- How to compile and run this C source!!!! (C++)
- Help - Run time error (Java)
- getting bad token ( on second compile (C#)
Other Threads in the C++ Forum
- Previous Thread: funtion that returns array?
- Next Thread: Polymorphism : doesn't work: massive of base class for derivated ones
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph homeworkhelp iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






