M
mdh
Hi All,
this little nonsense function is an attempt to understand function
pointers.
/*********/
#include <stdio.h>
void p(int);
int main (int argc, const char * argv[]) {
void (*q)(int) = p;
q(50); /* Question about this */
return 0;
}
void p(int i){
int j = i, k=1;
while ( i-- > 0)
printf("Print me %d times (iteration %2d)\n", j, k++);
}
/*****/
From my reading on p 120 I expected the call to p to be *q(50) and not
q(50) but *q gives an error. Paraphrasing K&R, q is a pointer to a
function, *q is the function and (*q)( arguments) is the call to it.
Could someone explain what I am missing?
Thank you.
this little nonsense function is an attempt to understand function
pointers.
/*********/
#include <stdio.h>
void p(int);
int main (int argc, const char * argv[]) {
void (*q)(int) = p;
q(50); /* Question about this */
return 0;
}
void p(int i){
int j = i, k=1;
while ( i-- > 0)
printf("Print me %d times (iteration %2d)\n", j, k++);
}
/*****/
From my reading on p 120 I expected the call to p to be *q(50) and not
q(50) but *q gives an error. Paraphrasing K&R, q is a pointer to a
function, *q is the function and (*q)( arguments) is the call to it.
Could someone explain what I am missing?
Thank you.