efn/c_save.c

18 lines
539 B
C

void
c_save(char *file) {
FILE *f = fopen(file + 2, "w");
if(f == NULL) { puts("couldnt open file."); return; }
Row *row = buffer;
while (1) {
for(int i = 0; i < ROW_SIZE; i++) {
if (row->text[i] == '\0' || row->text[i] == '\n')
break;
fwrite(&row->text[i], 1, 1, f);
}
fwrite("\n", 1, 1, f);
if (row->n == NULL) break;
row = row->n;
}
}