Reputation: 9
I need to concatenate two arrays of string and need to call the function with that string
I have two arrays
char q[4] = {'t','e','s','t'};
char w[4] = {'f','u','n','c'};
#define dump(a,b) a ## b
I have a function called
void testfunc()
{
...
..
}
if I call the macro dumb like dumb(q,w) this is just concatenating q and w, i need to concatenate the strings in that array.
Need to call the function by concatenating the arrays of string using macros. Is that possible??
Upvotes: 0
Views: 169
Reputation: 2013
I just want to call the function testfunc() which name is stored in two array char
Although you can't use macros in this case you could have an array for function pointers and select one you want to call at run time.
void (*p[NFUNCS])(void);
//...
p[0] = testfunc; /* store address of the function */
//...
(*p[0])(); // call to testfunc
Upvotes: 0
Reputation: 272537
No. Macros don't understand C constructs (such as arrays), they just perform simple text substitution.
Upvotes: 4