I'm trying to have the user hit the ENTER key to exit my program. I am using the
(void) getchar();
getchar function to wait for the user to press the ENTER key. This worked for a simple Hello world program that did not request any user input, but in this program with the user inputting a double, the program skips the getchar command. If I double-click on the "Lab 1B.exe" executable code, after the user inputs the double side A of the triangle, the executable window with the running program disappears (the program skips the getchar command). How do I get the program to wait for the user to type the ENTER key?
How do I get the program to wait for the user to type any key???
#include <stdio.h>
int main(void)
{
double a = 0, b = 0, c = 0;
//int x = 0;
double x = 0;
printf("Lab 1B - Triangles:\n\n");
printf("Enter the length of your triangle's side A: ");
scanf_s("%lf", &a);
printf("The length of the triangle's side A is: ");
printf("%lf", a);
printf("\n");
printf("\nPress the <ENTER> key to exit.\n");
(void) getchar();
//printf("\nEnter any value to exit: ");
//scanf_s("%i", &x);
//scanf_s("%lf", &x);
return 0;
}