C语言读取文件到字节数组
#include <stdio.h> #include <stdlib.h> char* readFileBytes(const char *name) { FILE *fl = fopen(name, "r"); fseek(fl, 0, SEEK_END); long len = ftell(fl); char *ret = malloc(len); fseek(fl, 0, SEEK_SET); fread(ret, 1, len, fl); fclose(fl); return ret; }