Created
December 9, 2013 01:17
-
-
Save nixpulvis/7866080 to your computer and use it in GitHub Desktop.
files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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