J
Jeff0803
Guest
I made a simple example for function pointer like fowlloing.
#include <stdio.h>
void printname(char* first_name, char* last_name)
{
printf("full name is %s, %s\n", first_name, last_name);
}
int main()
{
void (*printname)(char*, char*) = &printname; // Error occur here!
(*printname) ((char*)"James", (char*)"Bond");
return 0;
}
However an compile error occur from the line displayed in bold.
error C2440: 'initializing': cannot convert from 'void (__cdecl **)(char *,char *)' to 'void (__cdecl *)(char *,char *)'
Can anybody fix this?
Continue reading...
#include <stdio.h>
void printname(char* first_name, char* last_name)
{
printf("full name is %s, %s\n", first_name, last_name);
}
int main()
{
void (*printname)(char*, char*) = &printname; // Error occur here!
(*printname) ((char*)"James", (char*)"Bond");
return 0;
}
However an compile error occur from the line displayed in bold.
error C2440: 'initializing': cannot convert from 'void (__cdecl **)(char *,char *)' to 'void (__cdecl *)(char *,char *)'
Can anybody fix this?
Continue reading...