Message from C, C++ discussions
November 2019
— Don't use it, why would you? There surely is a better way to do it
My goal is to take a user input, if the user chooses something that is not an option, they say that is not an option and then ask the same question again
— Can you give me an idea of a better way to achieve this
— I really don't know what you want to do, so no idea
—
StringorInt Initial_Questions(void){
clearScreen();
char SorI;
puts("Do you want to create a String or an Integer Array?\n");
puts("Type I for an Integer Array or S for string Array\n");
scanf(" %c", &SorI);
switch(SorI){
case 'S':
return aSTRING;
break;
case 'I':
return INTEGAR;
break;
}
}
— Lets say i have a function like this that returns an enumeration , what would be the return value for the default case in the switch
— Still no idea
— Its a function that ask user if they want to make a string or integar array, Press I for int and S for string
— That character is stored in the SorI variable, which is passed in a switch
— Pass out of the two values in this enum
typedef enum{aSTRING,INTEGAR}StringorInt;
— My question is just about the default case in the switch statement
—
do{
scanf("%c", &SorI);
switch(SorI){
case 'S':
return aSTRING;
case 'I':
return INTEGAR;
} while(true);