I have a 2D array like this and I want a pointer to it.
Currently I have this:
char* recv_args_msg_queue[20];
char** ref_temp = &recv_args_msg_queue[0];
char*** ref_queue = &ref_temp;
But I feel my way is really dumb. Is there a way to do it on one line?
Note:
char* recv_args_msg_queue[20];
is later in my code allocated properly to be an array. I just wanted dynamic allocation otherwise I could have wrote:
char recv_args_msg_queue[20][another_number_here];
Using a typedef for your array type will make easier getting a pointer to it.
Your code would look like this:
typedef char* msg_queue20[20];
msg_queue20 recv_args_msg_queue;
msg_queue20* ref_queue = &recv_args_msg_queue;
Take care of reading the link I posted, as it contains important recommendations .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.