Message from C, C++ discussions

November 2019

— 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

Message permanent page

— 

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

Message permanent page

— 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);

}


}

Message permanent page

— This is the function where the issues happens

— If the user types in the create data type it works fine

— Choice is an enumeration called stringorInt that has two symbols, INTEGAR, or aSTRING, which we know at this point

Message permanent page