Anonymous
Hmmm
frakw
this is a hanoi tower program, i want to use while(1) to run next turn ,how to use realloc in this program ?
code:https://pastebin.com/Zqie9jsV
test:https://repl.it/@frakw/He-Nei-Ta-hanoi
Anonymous
Does anyone have experience with _Generic
Anonymous
In C , to make use of something similar to Typeof that you would find in high level languages
Anonymous
Anonymous
I read somewhere that you can use that with an enumeration to create something similar to Type dev
Anonymous
Anonymous
Or maybe I am wrong
Anonymous
Call back?
I think a call back is used for something like qsort
Anonymous
Maybe idk
Anonymous
Yes in interrupts too
Anonymous
Ya
Anonymous
Anonymous
Anonymous
Anonymous
Okay
Anonymous
ArrayData choose_Array_Member_Amount(InitialQuestionP Choose){
int ArrayMemberTotal;
int blue;
StringorInt choice = Choose();
ArrayData Array_Data;//1
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;
}
blue = scanf(" %d", &ArrayMemberTotal);
switch(blue){
case 1:
Array_Data.ArrayMemberTotal = ArrayMemberTotal;
return Array_Data;
break;
default:
break;
}
}
Anonymous
this is an function with the return type of a structure i created
Anonymous
the parameter is a typedef to a function
Anonymous
pointer
Anonymous
it calls that function and stores what that function returns which is an enumeration symbol i created , either aSTRING or INTEGAR
Anonymous
based on those options, it will print one of two statements
Anonymous
then it scanf for a variable called ArrayMemberTotal , if you put in an int like 2 , 4 , or something like that it works fine
Anonymous
but lets say there is an error on the user end, i want it to print a timed error message(i have a function that does that ) then re ask the qestions until and scan again
Anonymous
i tryed goto and it doesnt do what i am trying to do
Anonymous
Goto statement is only useful and must only be used for cleanup and not for retry
Anonymous
Anonymous
the program otherwise works , but if there is an error on the user end , like entering an Letter instead of an number, it doesnt work
Anonymous
maybe 12 hours drive for me lol
Anonymous
Alright I got your program flow. What I need to understand now is that what error are you talking about? Are you talking about the error when a user enters some arbitrary character other than INTEGER or aSTRING?
Anonymous
Why?
Anonymous
Anonymous
Alright
Anonymous
Anonymous
Put up a check for it before it goes into the switch
Anonymous
Anonymous
Anonymous
Mar!o
Dima
Lol
Anonymous
i want to fully grasp what i am doing before moving on
Anonymous
Anonymous
You've been told not to use goto
But you keep doing it
Anonymous
Anonymous
Anonymous
and i fixed all the other issues , its just this last one
Anonymous
I doesn't work that way
once i finish the book i want to do the three labs in the book , then read two more books , so i give my self to mid 2020 to get to this point
Anonymous
i am almost done with the 8th chapter in this 13 chapter book
Anonymous
You can understand some things only after a while
You will be relearning the stuff you think you got
Not rushing is good, but staying at one point for long time is not good either
Anonymous
Finish this damn project already😂
Anonymous
Finish this damn project already😂
i used loops to fix the other issues , this is actually a different issue , it works if users type in the correct input but lets say they put in a character and its scanning for an int i want to place an error message and ask the questions again
Anonymous
even trolls tossed a bone here and there
Anonymous
You good mate just carry on at your own pace if there isn't a time Constraint
Anonymous
Anonymous
That's nice
Anonymous
Anonymous
/report
klimi
no you havent
Anonymous
if you see choose() nested in the loop returns a values that is passed in the first switch , depending on the value passed in that switch it ask one of two question , and the i set a variable to the scanf so i can tell if it accepting the right type of input
Anonymous
Oh I havent?
Anonymous
@K11M1 maybe a light warning
klimi
Anonymous
lol, you guys sometimes lay the hammer down to quickly , maybe refer him to the pinned rules
Anonymous
@K11M1
klimi
but which point of rules? spam?
klimi
offtopic?
Anonymous
offtopic?
idk i only seen one comment from him so idk how much damage he did , but i have seen some noobs in here get eliminated almost instantly lol