Hi all,
I want to declare a variable whose name is decided by a variable value.
such as: if idx=0, then I need a new variable named var_00; if idx=1, then I need a new variable named var_01; ...; if idx=255, then I need a new variable named var_FF;
I don't know if it can be realized by '#' and '##', can anyone help me?
Thanks a lot!
I want to declare a variable whose name is decided by a variable value.
such as: if idx=0, then I need a new variable named var_00; if idx=1, then I need a new variable named var_01; ...; if idx=255, then I need a new variable named var_FF;
I don't know if it can be realized by '#' and '##', can anyone help me?
Thanks a lot!
C:
#include <stdio.h>
#include <stdint.h>
#define NAME(a) p_##a
int main()
{
uint8_t idx = 0;
uint8_t* NAME(idx) = NULL;
p_idx = &idx; // not p_idx, I want p_00;
printf("*p_idx = %d\n", *p_idx);
return 0;
}