S
Sune
Hi,
I'm stuck at the moment with the following:
I'm writing test functions for a module written in C. Since I'm lazy I
want to type as little as possible. I came up with this idea:
// Declare functions and an array of pointers to those functions
int t1(),t2();
int (*func[])() = { t1,t2 };
:
:
// Execute the functions in a for-loop like
for( int i=0; i<VAR1/VAR2; i++ )
{
if( (*func)() == BAD )
printf("Test nr: %d failed.\n", i );
}
So now I want to set VAR1 to the size of the array and VAR2 to the size
of a function pointer to get the number of test functions to execute.
Can someone, please show me how do I do that? I get compilation errors
when I use the sizeof operator for this.
Thanks in advance
/Sune
I'm stuck at the moment with the following:
I'm writing test functions for a module written in C. Since I'm lazy I
want to type as little as possible. I came up with this idea:
// Declare functions and an array of pointers to those functions
int t1(),t2();
int (*func[])() = { t1,t2 };
:
:
// Execute the functions in a for-loop like
for( int i=0; i<VAR1/VAR2; i++ )
{
if( (*func)() == BAD )
printf("Test nr: %d failed.\n", i );
}
So now I want to set VAR1 to the size of the array and VAR2 to the size
of a function pointer to get the number of test functions to execute.
Can someone, please show me how do I do that? I get compilation errors
when I use the sizeof operator for this.
Thanks in advance
/Sune