#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include "funcs.h"
int main(void) {
const char *file_name = "file.bin";
const char *choices = "Выберите действие:\n\t0 - закрыть программу;\n\t1 - вывести значения файла;\n\t2 - добавить значение;\n\t3 - удалить значение;\n\t4 - найти значение.\nВведите: ";
int choice;
printf("%s", choices);
while (1) {
scanf("%d", &choice);
while (getchar() != '\n'); // очистка буфера для ввода в другие функции нормально
if (choice == 0) {
printf("Программа закрыта.\n");
break;
}
else if (choice == 1) {
printf("\nВывод результатов:\n");
if (read_file(file_name) == 1) {
return 1;
}
printf("\n%s", choices);
}
else if (choice == 2) {
printf("\n");
if (add_value(file_name) == 1) {
return 1;
}
printf("\n%s", choices);
}
else if (choice == 3) {
printf("\n");
if (delete_value(file_name) == 1) {
return 1;
}
printf("\n%s", choices);
}
else if (choice == 4) {
printf("\n");
if (find_value(file_name) == 1) {
return 1;
}
printf("\n%s", choices);
}
else {
printf("\n%s", choices);
}
}
return 0;
}