-
This works:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
#if 1
/***** try out Kevin method ****/
typedef char char_array_50[50];
typedef char char_array_500[500];
char_array_500 *zz = (char_array_500*) malloc(sizeof(char_array_500)*2000); // allocate char[2000][500]
char_array_50 xx[30];
char_array_50* yy=(char_array_50*)&xx;
#else
/**** try out sef method ****/
char (*zz)[500] = (char (*)[500]) malloc(sizeof(char)*500*2000); // allocate char[2000][500]
char xx[30][50];
char (*yy)[50] = (char (*)[50])&xx;
#endif
xx[3][5] = 7;
xx[7][8] = 11;
printf("A test... The next line should print '7, 11'\n");
printf("%d, %d\n", yy[3][5], yy[7][8]);
return 0;
}
-
By the way, your code:
Code:
sht_pass_group = yy;
will never work for the reasons I stated earlier about how memory is organized.
- Kevin