I need to declare an array (in c) which holds two 2D arrays and one 1D array with different size and different type in it.
Unfortunately my google search not really helped...
int ram [128][64]; int chk_ram [128][64]; char arr_block[8]; Is it possible to pack these arrays in one big array?
@unwind: Here is my Function, it was originally a Python Function but because it was to slow i am now Trying to process these Arrays in C, because i expect that it´s much faster. The Function should act like a Blackbox i put 3 Arrays in and then there come 3 Arrays out which are going back to Python.
Here is the C Function (I think there are some mistakes in it):
#include <stdlib.h> #include <stdio.h> #include <math.h> int test(int **ram,int n_ram,int **chk_ram, int n_chk_ram,int **arr_block,int n_arr_block){ int i,j,k; int yDog,p,x,d,y,z; int *args_arr = (int*)malloc(size*sizeOf(int)); int *dog = (int*)malloc(size*sizeOf(int)); for (yDog=0;yDog<=8;yDog++){ p=yDog*8; line='' ?? /* ?? */ for (x=0;x<=128;x++){ d=0; if (chk_ram[(int)(x/16),yDog] == 1){ if (x%16 == 0){ arr_block[(int)(x/16),yDog] = ''; /* ?? */ } for (y=0;y<=8;y++){ z = pow(2,y) d += ram[x,p+y]*z; } arr_block[(int)(x/16),yDog] += chr(d); /* ?? */ if ((x+1)%16 == 0 && x){ chk_ram[(int)(x/16),yDog] = 0; line += arr_block[(int)(x/16),yDog]; /* ?? */ } } else{ if ((x+1)%16 == 0 && x){ chk_ram[(int)(x/16),yDog] = 0; line += arr_block[(int)(x/16),yDog]; x += 1; } else{ x+=15; } } } } dog[yDog] = line; /* ?? */ args_arr = {ram, chk_ram, arr_block) return args_arr; } I work with Ctypes if someone know this :)
typedef struct{int ram[128][64];int chk_ram [128][64];char arr_block[8];} MYARRAY;