Click here to Skip to main content
15,891,184 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how to pass two dimensional arrays in a function (c++) Pin
CPallini30-Apr-10 11:10
mveCPallini30-Apr-10 11:10 
GeneralRe: You are right, set array bounds. Pin
Software_Developer1-May-10 0:58
Software_Developer1-May-10 0:58 
GeneralRe: how to pass two dimensional arrays in a function (c++), please check Pin
mrby1233-May-10 12:27
mrby1233-May-10 12:27 
GeneralRe: how to pass two dimensional arrays in a function (c++), please check Pin
CPallini3-May-10 21:15
mveCPallini3-May-10 21:15 
GeneralRe: how to pass two dimensional arrays in a function (c++), please check Pin
mrby1234-May-10 5:56
mrby1234-May-10 5:56 
GeneralRe: how to pass two dimensional arrays in a function (c++), please check Pin
CPallini4-May-10 6:04
mveCPallini4-May-10 6:04 
GeneralRe: how to pass two dimensional arrays in a function (c++), please check Pin
mrby1234-May-10 6:22
mrby1234-May-10 6:22 
AnswerRe: how to pass two dimensional arrays in a function (c++) Pin
Software_Developer1-May-10 0:42
Software_Developer1-May-10 0:42 
>>void earth(float ihl[][], int go[][])
>>{
>>}
>>
>>I found these not working. How to pass these two dimensional arrays into a function?
>
>>Thanks

Hi. I came up with a hack. Simply define a size of the array in the function header like this : void earth(float ihl[3][3], int go[3][3]).

See Visual C++ code below.

#include <stdio.h>
#include <stdlib.h>


void add(int swap[3][2], int swap2[3][2]) 		/* Function definition 	*/
{
  int temp,i;

  for (i=0; i<3; i++)
  {
    temp       = swap[i][0];
    swap[i][0] = swap[i][1];
    swap[i][1] = temp;
  }
  return;
}



void display(int array[3][2],int array2[3][2]  ) 		/* Function definition 	*/
{
  int count=0,count1=0;

  for (count=0;count<3;count++)
    for (count1=0;count1<2;count1++)
      printf("%d ", array[count][count1]);

   printf("\n");
  puts("");
}

int main()
{
	int i[3][2]=  { {1,2}, {3,4}, {5,6}  };

  display(i,i);				/* i is a pointer	*/

  add(i,i);

  display(i,i);

  return 0;
}


...
GeneralRe: how to pass two dimensional arrays in a function (c++) Pin
mrby1231-May-10 18:56
mrby1231-May-10 18:56 
GeneralRe: how to pass two dimensional arrays in a function (c++) Pin
mrby1233-May-10 10:23
mrby1233-May-10 10:23 
QuestionHow to get application focus? Pin
Software200730-Apr-10 5:04
Software200730-Apr-10 5:04 
AnswerRe: How to get application focus? Pin
Randor 30-Apr-10 5:25
professional Randor 30-Apr-10 5:25 
QuestionRe: How to get application focus? Pin
David Crow30-Apr-10 9:06
David Crow30-Apr-10 9:06 
AnswerRe: How to get application focus? Pin
Patcher3230-Apr-10 11:52
Patcher3230-Apr-10 11:52 
QuestionWindows Installers Pin
Leif Goodwin30-Apr-10 3:07
Leif Goodwin30-Apr-10 3:07 
AnswerRe: Windows Installers Pin
Cedric Moonen30-Apr-10 3:18
Cedric Moonen30-Apr-10 3:18 
AnswerRe: Windows Installers Pin
KingsGambit30-Apr-10 4:30
KingsGambit30-Apr-10 4:30 
AnswerRe: Windows Installers Pin
rahul.kulshreshtha30-Apr-10 23:51
rahul.kulshreshtha30-Apr-10 23:51 
AnswerRe: Windows Installers Pin
Gary R. Wheeler1-May-10 2:09
Gary R. Wheeler1-May-10 2:09 
GeneralRe: Windows Installers Pin
jcdids2-May-10 15:55
jcdids2-May-10 15:55 
GeneralRe: Windows Installers Pin
Gary R. Wheeler3-May-10 1:07
Gary R. Wheeler3-May-10 1:07 
GeneralRe: Windows Installers Pin
Leif Goodwin4-May-10 3:48
Leif Goodwin4-May-10 3:48 
AnswerRe: Windows Installers [modified] Pin
Leif Goodwin4-May-10 3:46
Leif Goodwin4-May-10 3:46 
AnswerRe: Windows Installers Pin
Leif Goodwin25-May-10 5:43
Leif Goodwin25-May-10 5:43 
QuestionCaputre url change event Pin
Rajmohan SK30-Apr-10 2:42
Rajmohan SK30-Apr-10 2:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.