Probemwith functions in stdarg.h
I dont know english very well, so lets speak in C. (=
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
void simulation_scanner (char *name, int size, int TMP, int num, ...)
{
int i,j;
va_list arguments;
double (*foo[num])(struct OBJ); /* 1 */
va_start (arguments,num);
for (i=0;i<num;i++)
foo[i] = va_arg(arguments, (???) ); /* 2 */
va_end (arguments);
double data[TMP][num];
struct OBJ *T = mkobj(size);
for (i=0;i<TMP;i++)
{
simulation_step(T);
for (j=0;j<num;j++) data[i][j] = foo(*T);
}
write_on_file(name,data,TMP,num);
return;
}
|
I'll use the function this way:
1 2 3 4 5 6 7
|
{...}
double density (struct OBJ T) { return T.occ / T.size; }
double inp (struct OBJ T) { return T.input; }
double out (struct OBJ T) { return T.out; }
{...}
simulation_scanner ("Test01", 150, 200, 3, &density, &inp, &out);
{...}
|
/* 1 */It's a array of functions!?! If not, how I do it right?
/* 2 */What (???) should be? (double*)(struct OBJ) ?
Topic archived. No new replies allowed.