S
Sam
Hi there. I hope this code is standard C. I think it is. Anyway, I
haven't used C in a Looooooong time and am a little rusty on pointers.
I am wondering why "buff" is a pointer to a pointer instead of just
"*buff". I'm also not really sure about the language of pointers. Is
it correct to say "pointer to a pointer to buff" or "double pointer to
buff" or what? If you can help me with this, you have my thanks...
REM --- *Code Below* ---
void LoadFileIntoMemory(const char *name, void **buff, int *length)
{
FILE *fp = fopen(name, "rb");
fseek(fp, 0, SEEK_END);
*length = ftell(fp);
fseek(fp, 0, SEEK_SET);
*buff = malloc(*length);
fread(*buff, *length, 1, fp);
fclose(fp);
}
REM --- *End Code* ---
haven't used C in a Looooooong time and am a little rusty on pointers.
I am wondering why "buff" is a pointer to a pointer instead of just
"*buff". I'm also not really sure about the language of pointers. Is
it correct to say "pointer to a pointer to buff" or "double pointer to
buff" or what? If you can help me with this, you have my thanks...
REM --- *Code Below* ---
void LoadFileIntoMemory(const char *name, void **buff, int *length)
{
FILE *fp = fopen(name, "rb");
fseek(fp, 0, SEEK_END);
*length = ftell(fp);
fseek(fp, 0, SEEK_SET);
*buff = malloc(*length);
fread(*buff, *length, 1, fp);
fclose(fp);
}
REM --- *End Code* ---