H
Hans Ginzel
Hello,
let us consider function
int foo(char *name, void *data) {
...
printf(name, data); /* Should be *data? */
...
}
and calling
double epsilon=1e-5;
foo("epsilon: %lg\n", &epsilon);
Function foo could change data, sopointer is needed.
Data could be of different type (int, double, long int),
but always is passed corresponding format (%...) for printf in `name'.
How to program this correct? How to correct dereference variable `data'?
gcc warns about derefencing void variable.
Or how to say it to printf, that it should dereference it's argument?
Thanks
Hans Ginzel
let us consider function
int foo(char *name, void *data) {
...
printf(name, data); /* Should be *data? */
...
}
and calling
double epsilon=1e-5;
foo("epsilon: %lg\n", &epsilon);
Function foo could change data, sopointer is needed.
Data could be of different type (int, double, long int),
but always is passed corresponding format (%...) for printf in `name'.
How to program this correct? How to correct dereference variable `data'?
gcc warns about derefencing void variable.
Or how to say it to printf, that it should dereference it's argument?
Thanks
Hans Ginzel