# Dissapearing c programs



## hammil (Jun 26, 2007)

Hi
I have just started to program in C using Miracle C compiler, but when I run programs it shows the output for a sec but then disappears.

Hamish :grin:


----------



## shuuhen (Sep 4, 2004)

In Windows, the DOS window will exit as soon as the program completes if you didn't already have the DOS window open.

A simple solution is to have a UserWait() function. Basically all this function will do is print a message telling the user to press return then wait until the user has pressed return.

system("PAUSE") will also wait for the user to press a key, but it's bad practice since it relies on the pause.exe program. system("PAUSE") will only work on Windows. Implementing a UserWait() function with printf() a do-while loop and getchar() should work fine on all systems.

If you need help implementing a UserWait() function, I can help after you post a first attempt.


----------



## hammil (Jun 26, 2007)

OK, I tried doing that but it came with this error:


```
Linker Error (Severity 4)
	Module "a" in file "c:\program files\miracle c\test.obj"
	references unresolved external "_userwait"
	at offset 0578H in segment "_text".
```
Do I have to include any header files?

Hamish:grin:


----------



## shuuhen (Sep 4, 2004)

Can you post your code? You'll need stdio.h for both getchar() and printf().


----------

