Subj : Re: Windows Prompt Runtimes SHORT-Debug To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Mon Jun 21 2004 12:17 pm What do you mean by "runs short"? If you mean that the program runs quickly, of course it does. Your program has very little in it. There is an error in what you show, this line is wrong #include If you want to include both files then you need to do so individually like this: #include #include And if you are not using getch() then why are you including conio.h? There also is another error in the program, a logical error. You used scanf but did not use it correctly. The function stops at the last character which meets its input specification, leaving the following character in the input buffer. That following character is the enter key. When you called getchar() , it did what it was told, read the remaining character. You either must read in that character before doing more input or handle it in some other way. That is part of the reason that the function sscanf is more commonly used instead of scanf. It does not share this behavior. Here are two versions of your program, both of which work. The second uses sscanf. Both also show the return type for main as the default of 'int' has been removed from the language specification. Both use an 'else' on mutually exclusive 'if' statements. Both change the two initial 'printf' calls which are used to write one prompt to one call because the second is not needed. ----using scanf------------------ #include int main() { int num1, num2; printf("Enter two integers, and I will tell you\n" "the relationships they satisfy: "); scanf("%d%d", &num1, &num2); if (num1 == num2) printf("%d is equal to %d\n", num1, num2); else if (num1 != num2) printf("%d is not equal to %d\n", num1, num2); if (num1 < num2) printf("%d is less than %d\n", num1, num2); else if (num1 > num2) printf("%d is greater than %d\n", num1, num2); if (num1 <= num2) printf("%d is less than or equal to %d\n", num1, num2); if (num1 >= num2) printf("%d is greater than or equal to %d\n", num1, num2); getchar(); /* swallow the '\n' that scanf left in the input buffer */ printf("Press enter..."); getchar(); return 0; } ----using sscanf------------------ #include int main() { int num1, num2; char input_buffer[133]; printf("Enter two integers, and I will tell you\n" "the relationships they satisfy: "); fgets(input_buffer, sizeof(input_buffer), stdin); /* read input */ sscanf(input_buffer, "%d%d", &num1, &num2); /* scan it */ if (num1 == num2) printf("%d is equal to %d\n", num1, num2); else if (num1 != num2) printf("%d is not equal to %d\n", num1, num2); if (num1 < num2) printf("%d is less than %d\n", num1, num2); else if (num1 > num2) printf("%d is greater than %d\n", num1, num2); if (num1 <= num2) printf("%d is less than or equal to %d\n", num1, num2); if (num1 >= num2) printf("%d is greater than or equal to %d\n", num1, num2); printf("Press enter..."); getchar(); return 0; } ---------------------- .. Ed > Jeremy Pham wrote in message > news:40d6dbaf$1@newsgroups.borland.com... > > Man, too bad I'm not expert. I did some revisions and prompt is > still short. I'll need help revising. Here's the first program: .... .