Last active
May 20, 2021 15:52
-
-
Save alsamitech/286558325c16b44d2f183787e9c42738 to your computer and use it in GitHub Desktop.
read_file - Reads a file from disk.
This file contains hidden or 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
| char* read_file(char* filenm, long unsigned int* len){ | |
| char* buf=0; | |
| FILE* f=fopen(filenm, "rb"); | |
| if(f){ | |
| fseek(f,0,SEEK_END); | |
| *len=ftell(f); | |
| fseek(f,0,SEEK_SET); | |
| buf=(char*)calloc(1, *len); | |
| if(buf) | |
| fread(buf, 1, *len, f); | |
| fclose(f); | |
| } | |
| return buf; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment