I've only just started to learn C++, I'm currently trying to build a program that will run several programs inside itself, all of which can be accessed by a main menu, I've managed with some help to make a multiplication chart come up as my first program the user can choose, but I can't really figure out how to get the program to clear the screen and bring the main menu back up, the issue is that what I've tried so far: getchar()
, return 0;
, system("PAUSE")
only halt the for loop that I have after one line has been printed, and in some cases you have to hit enter every single line. So is there a way I could get the entire chart to print and have it sit on screen until the user closes it with a specific key, that key also clearing the screen and bringing my main menu back up? Thanks in advance, I've done some searching but I'm rather confused at the moment.
Here's what I've written so far, this is my menu and my charts loop...
printf("\n******************************************************");
printf("\n******************************************************");
printf("\n** Hello and welcome to my program! **");
printf("\n** Please select the program you would like to run! **");
printf("\n******************************************************");
printf("\n** - 1. Multiplication table **");
printf("\n** - 2. Program B - **");
printf("\n** - 3. Program C - **");
printf("\n** - 4. Program D - **");
printf("\n******************************************************");
printf("\n******************************************************");
printf("\n ");
scanf("%d", &selection);
system("CLS");
switch (selection) {
case 1:
int i, j;
printf (" |");
for (i = 1; i <= 10; ++i)
printf ("%#3d ", i);
printf ("\n");
for (i = 1; i < 64; ++i)
printf ("-");
printf ("\n");
for (i = 1; i <= 10; ++i) {
printf ("%#2d |", i);
for (j = 1; j <= 10; ++j)
printf ("%#3d ", i * j);
printf ("\n");
}
break;