[Solved] struct in c getting problematic, at verge of improper result [closed]


From your code – assuming the function stats is being executed one per game iteration. the gamesStruct local variable is being destroyed at end of stats and being declared (and initialized) again and again.

this is why the previous result is cleared.

you should declare the gamesStruct at tge calling API and pass it by reference to the stats method.

int stats(GAMEST& gamesStruct, int res,int gamenum,int step,float tim,int counter)
{
   ...  // same as before
}

(pay attention to create the gamesStruct before calling the iteration and destroy it properly if dynamically allocated.

5

solved struct in c getting problematic, at verge of improper result [closed]