Computers |
|
| | #1 (permalink) |
| Ultra Techie | i was just quickly reading through an online guide to refresh my knowledge of C programming, and i just cant figure out why this program won't wait to display the results! I'm sure there is something else wrong, but i can't debug it really, because i can't run it. I remember adding the following to the program, but that doesnt work. Code: getchar(); return 0; Code: #include <stdio.h>
int main()
{
int num;
printf( "Please enter a Number: " );
scanf( "%d", &num );
if (num == 1234) {
printf( "congratulations! \n" );
printf( "you have guessed my number: ", num);
}
else {
printf( "error: Wrong Number\n");
}
getchar();
return 0;
} what can i do to make this work properly (well maybe not properly, but pause at the end of the program before quiting)? thanks!
__________________ Life is good with SparkCash =) |
| | |
| | #4 (permalink) |
| Ultra Techie | i remember trying the system("PAUSE") but i put it after the return 0... makes more sence to put it before though i think getch() is suiting my needs more, but system("PAUSE") will definatelly come in handy!! thanks edit: lol, yea, not really sure why i was putting in getchar()... i was thinking "fuction get character"... stupidity
__________________ Life is good with SparkCash =) |
| | |