I am currently trying to copy the contents from a single dimension array to a multiple dimension array using pointer notation. I though am having problems doing so. Can someone out there show me how to program a multiple dimension array that will take from a single dimension array? Listed below is sample code that I am trying to get to work.
Code:
#include <stdio.h>
#define SIZE 5
#define SIZE2 5
#define ROWS 2
void transarr4(int *(*(arry)), int * arry2, int row); //Pointer Notation (Multiple Dimension Array)
int main(void)
{
int arr[SIZE] = {100,200,300,400,500};
int arr2[ROWS][SIZE2] = {{},{}};
int *(*(arr3)) = 0;
transarr4(arr3,arr,ROWS); //Pointer Notation (Multiple Dimension Array)
return 0;
}
//====================================================================================================
// Pointer Notation (Multi-Dimension Array)
//====================================================================================================
void transarr4(int *(*(arry)), int * arry2, int row)
{
int num = 0;
int r = 0;
int c = 0;
for(r = 0; r < row; r++)
{
for(c = 0; c < SIZE2; c++)
{
//arr[r][c] = arr2[c];
*(*(arry)) = arry2[c];
printf("%d",*(*(arry + r)+c));
printf("\n");
}
}
}