Message from C, C++ discussions
November 2019
— Each function calls the next function in the very beginning of the function
So the user first sees the questions of the last function , Initial question first , since choose array member amount is dependent on what is returned by initial question , and the create array function is dependent on what is returned from choose_Array_Member_Amount
— So i see the intial questions first, asks you if you want to make a string or int array, lets say i choose int , it then returns that data to the next function
— If i enter a wrong input it uses the default case, which calls the “function X” which in this case is the not an option () funciton which just displays a timed error message and clears the screen , then it makes use of recursion all calls itself again , to re ask the question
— Up to this point it works fine
— Its when it collects that data and passes it to the next function where the program gets weird
— Choose_Array_Member_Amount function , which is what called the intial question function in the first place now has the data it needed from the initial question function and stores it in a variable called Choice
— Choice is passed it a switch statement
— God I lost it
— Because choice is an enumeration , a default case is not needed
—
ArrayData choose_Array_Member_Amount(InitialQuestionP Choose){
int ArrayMemberTotal;
StringorInt choice = Choose();
ArrayData Array_Data;
Array_Data.chooseStringorInt = choice;
clearScreen();
switch(choice){
case INTEGAR:
puts("How many members do you need in your Integer Array?\n");
break;
case aSTRING:
puts("How many members do you need in your String Array?\n");
break;
}
if(scanf(" %d", &ArrayMemberTotal)){
Array_Data.ArrayMemberTotal = ArrayMemberTotal;
return Array_Data;
}
else if(scanf(" %d", &ArrayMemberTotal) != 1){
not_An_Number();
switch(choice){
case INTEGAR:
puts("How many members do you need in your Integer Array?\n");
break;
case aSTRING:
puts("How many members do you need in your String Array?\n");
break;
}
scanf(" %d", &ArrayMemberTotal);
}
}
— This is the function where the issues happens