include #include #include #include #include "string.h" #include "vector.h" #include // To fix: // Freeing on close // Proper flow #define DEBUG_MODE 1 typedef struct EditorFile { String content; } EditorFile; int open_file(EditorFile* pef, char* filename) { FILE* pf = fopen(filename, "r"); if (!pf) { perror("fopen"); return EXIT_FAILURE; } // build a string until the end of the file is reached String sb = String_New(16); int c; while ((c = fgetc(pf)) != EOF) { String_AppendChar(&sb, c); } if (ferror(pf)) { return 1; } pef->content = sb; return 0; } holy code