I have had a look around on other forums and lots of googling, tried about 5 different lines of code to try and get this thing to pause after outputting but It just won't work.
I'm using Dev-C++ on Windows 7 64bit.
#include <stdio.h>
int main()
{
int b;
printf("Enter a value:");
scanf("%d", &b);
if (b < 0)
printf("The value is negative\n");
getchar();
return 0;
}
As you can see my most recent attempt was to use getchar to pause it but after I enter the number, It just outputs "the value is negative" and closes almost instantly, barely enough time to read it.
P.S First time learning C or any language for that matter.
Anyone got any ideas how I can get it to wait for me to hit a key and then exit?
Thanks and sorry again.


Sign In
Create Account


Back to top










