Skip to content

Instantly share code, notes, and snippets.

/server.c Secret

Created December 24, 2016 17:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/a3ee4337ab2dbec44d1045714dc365c2 to your computer and use it in GitHub Desktop.
Save anonymous/a3ee4337ab2dbec44d1045714dc365c2 to your computer and use it in GitHub Desktop.
server.c - shared from CS50 IDE
bool load(FILE* file, BYTE** content, size_t* length)
{
// TODO
char * buffer = malloc(BYTES);
if(file == NULL)
{
printf("cannot open file");
return false;
}
else
{
{
while(!EOF)
{
buffer = (char *)realloc(buffer, sizeof(BYTES));
fread(buffer, sizeof(BYTE), BYTES, file);
}
*content = buffer;
*length = sizeof(buffer);
free(buffer);
}
return true;
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment