Embed Notice
HTML Code
Corresponding Notice
- Embed this notice@kirby I'm not exactly sure what you're trying to do there.
If you want to open a file for reading and save it to a buffer for some reason, I would do;
#include <sys/stat.h>
FILE *fp = fopen("/home/chris/file", r);
//get filesize, will be in stat.st_size
struct stat stat;
stat(fp, &stat);
char *sneed = malloc(stat.st_size);
fread(sneed, 1, stat.st_size), 1, fp);
puts(sneed);
free(sneed);
fclose(fp);
But that's a terribly broken program, I reckon I can achieve what you want to do much cleaner with like 10 lines.