ofirg
asked on
how can i pass #define to function as an argument
suppose i have
#define DEF1 {1,1}
#define DEF2 {2,2}
int func(x)
{
int *i = x ;
return 0;
}
what should be x?
#define DEF1 {1,1}
#define DEF2 {2,2}
int func(x)
{
int *i = x ;
return 0;
}
what should be x?
ASKER
i want to pass the #define itself to function as an argument not by assign it to other variable first
somthing like
i = func( (int*) DEF1);
somthing like
i = func( (int*) DEF1);
The constans DEF1 and DEF2 are recognized all over the program , including inside the function.
Why do you want to pass it ?
Why do you want to pass it ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
But the question is quite ambiguous and, candidly silly. So why not describe what you really want to do?
-- Dan
-- Dan
ASKER
thanx man.
const int DEF1[] = {1,1}; works and help me very much.
const int DEF1[] = {1,1}; works and help me very much.
You need to allocate it:
int anTwoElemArray[2]= DEF1; // {1,1}
int nRet= func( anTwoElemArray );
or
int nRet= func( &anTwoElemArray[0] );
or
int* pan= anTwoElemArray; // point to first element
int nRet= func( pan );
But the question is quite ambiguous and, candidly silly. So why not describe what you really want to do?
-- Dan