I am trying to pass a pointer to a 3D array to a function in which I want to access an array element using pointer arithmetic.

Define the array:

const unsigned char TS_list_string[2][2][3] = 
 "abc",   "def", 
 "ghi",   "jkl",  

Define the function

void process_ts(const unsigned char *T1)
unsigned char dv;

    dv = *(*(*(T1 + 1) + 1) + 2);  <----- Compiler error: "Operand of * must be a pointer


int main()      
const unsigned char  *T1;

   T1 =  &TS_list_string[0][0][0];

   process_ts( T1);

Does anyone know what I am doing wrong?

Recommended Answers

All 2 Replies

Does anyone know what I am doing wrong?

Mainly, if it's supposed to be a string, where's the space for the \0 that terminates a string?

Yes, the last dimension should be 4 rather than 3 to store the terminator. But that is not the problem, which you do not address.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.