Hello,
I can't seem to find any example code where a 2-dimensional array is returned from the function. This is my code:

char *updateBoard(char board[3][3], int position, char piece){
          //board is changed here
         //want to return new board
	
	return board;
}

any suggestions are much appreciated.

Recommended Answers

All 3 Replies

You don't need to return anything, as changing the board inside the function will change the board in the caller.

Arrays are always passed as a pointer, even if you don't use any pointer notation in the definition of the function parameters.

thanks :$ i should have realised that!

can you plaese show us how is that being done in simple program?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.