c - return a pointer struct from a function -
I 'switch' the user input of that row and column (this is called a game teaser), but I'm not sure That is how I return the value I want back to.
The warning I received is:
WARNING: Indicator for the incompatible integer conversion 'slipping' * from the result type 'int' [-vng-conversion]
typedef struct {int row; Int column; } Trick; / * Function: getNextMove * Description: Ask the user for a new trick or if the user * wants to leave * the game. * Input: An indicator for a move structure. The coordinates for the next step * or a hint from the user to end the game * Output: Return 0 if users want to end the game, otherwise 1. * Return coordinates to the next game through the structure * indicate the structure * / Int getNextMove (go ahead next) {printf ("Create a move (line = 0 game ends) \ n"); Printf ("line ="); Scanf ("% d", and next->;); If (uplammer->; == 0) {return 0; } Printf ("column ="); Scan ("% d", and algor-> columns); Go ahead; }
You should not return more than one value as suggested by the function banner comment . Return to 0 or 1 to indicate the position of the game and the value stored on the address indicated by the next MV has been replaced by scanf () function calls:
int getNextMove ) [Printf ("Make a move (rows = 0 game ends) \ n"); Printf ("line ="); Scanf ("% d", and next->;); If (uplammer->; == 0) {return 0; } Printf ("column ="); Scan ("% d", and algor-> columns); Return 1; }
If you want to return a pointer to a move for the record, then an example can be:
move * getMove (void) {Static move move; / * On some running storge / operation] / return and left turner}
Comments
Post a Comment