i am looking for help on sudoku.c. i need to store the original numbers that come with the board so that the number values can not be changed. i am having trouble figuring out how to store these values. i am a beginner, especially with pointers. i have tried to write functions for this, as well as put the nested for loop right into main. i am looking for some pointers (pun intended) on how i can access these values. right now my function for making an initial board array is some variation similar to this:

int make_init (*init_board[9][9])


     for (int i =0; i < 8;*i ++)

             for (int j = 0; j < 8; j++)

                g.init_board[i][j] = g.board[i][j];

       return ?;


im just looking for some general advice into how and what need *'s and why, and what to return. etc. so i can think it through and research better.thanks for any help


A few tips that might steer you in the right direction...

  1. You don't need to use pointers (directly) for copying the grid. Bracket syntax for arrays, as in g.board[i][j], is syntactic sugar for pointer arithmetic. The Wikipedia article on syntactic sugar uses this example specifically. I suggest watching Doug's short on pointers if confusion remains as to how/when to use them.
  2. It looks like you are trying to copy into g.init_board. However, anything following g. must be a part of the struct as defined at the top of sudoku.c. Did you add a field to the pre-defined struct? Alternatively, did you declare a separate global variable corresponding to the size of g.board, in which case you would not append g. to the front?
  3. I suggest giving this function a void return type. You don't need to return anything to the calling function; you just need to copy the values from one array into another.

You may find it helpful to watch the walkthrough from 2011 found here.

  • Thanks Peter, thats awesome, this helps immensely!! Im looking forward to using and/or researching all of that great advice. Yes, i did add init_board[9][9] into the g struct, and i was using g. some of the time but started trying all kinds of different stuff, so i will move back to that. I appreciate it a lot man
    – G-REG
    May 20 '17 at 4:14
  • You are welcome. Best of luck with sudoku!
    – Peter
    May 20 '17 at 5:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .