Question related to returning to earlier parts of the code.
I was wondering if it was possible to return to a previous part of the code. I will use a small example. I apologize if this is a n00by question.
Code:
#include <stdio.h>
#include <string.h>
int main()
{
int selection;
char color[10];
int bunk;
printf("Select what you would like to do\n\n");
printf("\n\n1.) Tell me about colors");
printf("\n2.) The second option");
printf("\n\nEnter command: ");
scanf("%d", &selection);
switch (selection) {
case 1:
printf("\n\nwhich color would you like to know about?\n\n");
scanf("%s", color);
break;
case 2:
printf("\n\noh hello");
break;
}
if( strcmp( color, "green" ) == 0 ) {
printf("\n\nGreen is made up of both blue and yellow");
}
scanf("%d", bunk);
getchar();
}
How would I get the program to return to the switch case (the selection with the int input)?