User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,515 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,766 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1575 | Replies: 3
Reply
Join Date: Oct 2007
Posts: 2
Reputation: dc101 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dc101 dc101 is offline Offline
Newbie Poster

Question Returning 2-dimensional array, how?

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

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

any suggestions are much appreciated.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: Returning 2-dimensional array, how?

  #2  
Oct 3rd, 2007
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.
Reply With Quote  
Join Date: Oct 2007
Posts: 2
Reputation: dc101 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
dc101 dc101 is offline Offline
Newbie Poster

Re: Returning 2-dimensional array, how?

  #3  
Oct 3rd, 2007
thanks i should have realised that!
Reply With Quote  
Join Date: Aug 2007
Posts: 22
Reputation: alsoumhi is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
alsoumhi alsoumhi is offline Offline
Newbie Poster

Re: Returning 2-dimensional array, how?

  #4  
Oct 4th, 2007
can you plaese show us how is that being done in simple program?
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 3:58 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC