Загрузка данных


int read_contacts(Contact *contacts)
{
    FILE *file = fopen_or_exit(FILEBASE, "rb");

    /*
        Считываем количество контактов.

        TODO: добавить проверку fread.
    */
    uint8_t contacts_count;
    fread(&contacts_count, sizeof(uint8_t), 1, file);

    for (uint8_t i = 0; i < contacts_count; i++) {
        char *name = NULL;
        char *phone = NULL;

        read_string(name, file);
        read_string(phone, file);

        contacts[i]->name = name;
    }

    fclose(file);
    return 1;
}