S
Sortie
Is a function name in C treated the same as a pointer to that
function? For example, the following program compiles and runs
fine:
#include <stdio.h>
#include <stdlib.h>
int callback(int x){return x;}
void print_callback(int cb()){
printf("%d\n", cb(10));
}
int main(int argc, char *argv[]){
print_callback(callback);
return 0;
}
If so, why should I explicitly use a pointer to a function?
function? For example, the following program compiles and runs
fine:
#include <stdio.h>
#include <stdlib.h>
int callback(int x){return x;}
void print_callback(int cb()){
printf("%d\n", cb(10));
}
int main(int argc, char *argv[]){
print_callback(callback);
return 0;
}
If so, why should I explicitly use a pointer to a function?