read entire file c code example
Example: read entire file c
char *read_file_content_path(char const *filepath)
{
FILE *file = fopen(filepath, "r");
int file_size;
char *text;
fseek(file, 0L, SEEK_END);
file_size = ftell(file);
rewind(file);
text = malloc(file_size + 1);
fread(text, 1, file_size, file);
text[file_size] = '\0';
fclose(file);
return text;
}