efn/c_open.c

22 lines
404 B
C
Raw Normal View History

void
2022-04-02 12:46:20 +00:00
c_open(char *file) {
FILE *f = fopen(file + 2, "r");
if(f == NULL) { puts("couldnt open file."); return; }
b_truncate(buffer);
Row *row = buffer;
while (1) {
size_t red = 0;
for (int i = 0; i < ROW_SIZE; i++) {
red = fread(&row->text[i], 1, 1, f);
if (red != 1) return;
if (row->text[i] == '\n') {
row->text[i] = 0;
break;
}
}
row = b_insert(row);
}
fclose(f);
2022-04-02 12:46:20 +00:00
}