while reading an old thread I found this bit of code. I was wondering if anyone could explain to me the components of the function declaration. I tried using this code, but I got a warning when i tried to compile it, and a link error while attempting to run it. The warning states that Callback is undefined. And the link error states that there is an unresolved external symbol _Callback. I think Prelude is the one who supplied this code, so maybe that's who I need to ask in order to clarify.
Code:
int ReadLines(const char *Filename, ReadLineFunc Callback)
{
FILE *fp = fopen(Filename, "r");
char hex2[512];
char *copy;
if(fp == NULL) {
fprintf(stderr,"Error, file is not found. \n");
return -1;
}
/* Read each line and print it out */
while(fgets(hex2, 512, fp) != NULL) {
copy = malloc ( strlen ( hex2 ) + 1 );
if ( copy != NULL ) {
strcpy ( copy, hex2 );
Callback(copy);
free ( copy );
copy = NULL;
}
}
fclose(fp);
return 0;
}