Загрузить файлы в «/»

This commit is contained in:
8nlight 2023-11-01 19:56:13 +03:00
parent b201477146
commit 35bb793284

20
main.c
View File

@ -14,10 +14,21 @@ size_t cursor;
void die(char *msg) { void die(char *msg) {
endwin(); endwin();
printf("%s: %s\n", msg, strerror(errno)); printf("%s: %s\n", strerror(errno), msg);
exit(1); exit(1);
} }
void export(void) {
FILE *fp = fopen("export", "a");
if (fp == NULL)
die("");
for (size_t i = 0; i < timer_size; i++)
fprintf(fp, "%ld%ld,", timer[i].sec, timer[i].msec / 10);
fclose(fp);
}
void add_value(clock_t sec, clock_t msec) { void add_value(clock_t sec, clock_t msec) {
timer_size++; timer_size++;
@ -57,6 +68,11 @@ void keyboard(clock_t sec, clock_t mcsec) {
clear(); clear();
break; break;
case 'e':
endwin();
export();
exit(0);
case 'q': case 'q':
endwin(); endwin();
exit(0); exit(0);
@ -106,7 +122,7 @@ int main(void) {
clock_t sec = mcsec / 1000000; clock_t sec = mcsec / 1000000;
clock_t msec = (mcsec / 100000) % 10; clock_t msec = (mcsec / 100000) % 10;
mvprintw(1, 2, "[q - quit] [' ' - add mark] [w/s - control] [p - pause]"); mvprintw(1, 2, "[q quit] [e export] [' ' add mark] [w/s control] [p pause]");
mvprintw(3, 2, "%ld.%ld", sec, msec); mvprintw(3, 2, "%ld.%ld", sec, msec);
print_timer(); print_timer();