| jakeboii69 (9) | |
|
i have wrote my "Hello World" code but now want it to stall afta being decoded so that command prompt exit when you press a key. i have used the following to try and do it but it doesnt seem to be working: #include <iostream> using namespace std; int main() { cout<<"Hello World"; cout<<"Press any key to destroy the World mwhahaha!"; system ("PAUSE");//this line doesnt seem to work return 0; } | |
|
|
|
| Bazzy (6275) | |
Try cin.ignore( 256, '\n' ); insteador, if you want to get any key input use kbhit() from conio.h | |
|
Last edited on
|
|
| jakeboii69 (9) | |
| i have inputted that instead of system ("PA...... and it still brings up an error message. it says; unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? | |
|
|
|
| Bazzy (6275) | |
|
Which template did you choose when you created that project? ( If you are using VC++ you sould start from Empty Project without clr or anything ) | |
|
Last edited on
|
|
| jakeboii69 (9) | |
| I think that was the reason it wasnt working but i just copied and pasted a code from the variables tutorials into VC++ and it doesnt let that run. it says the same error message again:S | |
|
|
|
| Bazzy (6275) | |
|
On my VC++ works fine... Try to #include "stdafx.h" ( if you don't have stdafx.h, just create it as empty file ) | |
|
|
|
| Warrior2089 (91) | |||
|
Try this: #include <iostream> using namespace std;
Cin.get() will wait for an input from the user before closing. | |||
|
|
|||
| helios (9442) | |
|
See, here's the problem with VC++: The default project configuration sucks balls. You can either create a new empty project or do this: Go to project properties (right click on the project, at the bottom), C/C++>Precompiled Headers>Create/Use Precompiled Header>Not Using Precompiled Header. Now remove everything from the project that isn't the main .cpp. That should do it. | |
|
|
|