Skip to content

Instantly share code, notes, and snippets.

@nixpulvis
Created December 9, 2013 01:17
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 nixpulvis/7866080 to your computer and use it in GitHub Desktop.
Save nixpulvis/7866080 to your computer and use it in GitHub Desktop.
files
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
int main(int argc, char const **argv) {
FILE *f = fopen("foo.bmp", "rb");
fseek(f, 0, SEEK_END);
long fsize = ftell(f);
fseek(f, 0, SEEK_SET);
unsigned char *data;
if ((data = malloc(fsize + 1)) == NULL) {
perror("malloc");
}
fread(data, fsize, 1, f);
fclose(f);
printf("%x\n", data[fsize-1]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment