I need to make a simple DB in C using structures. I can make const size, but i want to increase size every time i add new element. Here is structure and functions to add and print.
typedef struct PASSPORT
{
    char    name[25];
    char surname[25];
    char address[25];
    int          day;
    int        month;
    int         year;
}passport;
int iterator = 0; //position in mas of passport
passport* add_pas(passport** pas)
{
    int scan_status = 187;
    *pas = realloc(*pas, sizeof(*pas) + sizeof(passport));
    if (*pas == NULL)
    {
        printf(" \nNULL prt in realloc");
        exit(-1);
    }
    printf("\n Enter surname: ");
    scan_status = scanf(" %25s", (*pas)[iterator].surname);
    printf(" Enter name: ");
    scan_status = scanf(" %25s", (*pas)[iterator].name);
    printf(" Enter street address: ");
    scan_status = scanf(" %25s", (*pas)[iterator].address);
    printf(" Enter date of birth(dd/mm/yyyy): ");
    scan_status = scanf("%d/%d/%d", &(*pas)[iterator].day, &(*pas)[iterator].month, &(*pas)[iterator].year);
    ++iterator;
    return (*pas);
}
void print_all_passports(passport* pas, FILE* file)
{
    for (int i = 0; i < iterator; ++i)
    {
        printf("\n---------------------------");
        fprintf(file, "\nPASSPORT %d: ", i + 1);
        printf("\n Surname: ");
        fprintf(file, "%s", pas[i].surname);
        printf("\n Name: ");
        fprintf(file, "%s", pas[i].name);
        printf("\n Address: ");
        fprintf(file, "%s", pas[i].address);
        printf("\n Date of birht: ");
        fprintf(file, "%d/", pas[i].day);
        fprintf(file, "%d/", pas[i].month);
        fprintf(file, "%d", pas[i].year);
    }
    printf("\n---------------------------\n");
}
So, actually it works: i can add elements and print them, BUT before exiting the program in main it throws an exception and says: wntdll.pdb contains the debug information required to find the source for the module ntdll.dll. Also i have a warninig when i realloc.
I am a new at c/c++, i understand that maybe i make smt wrong with memory an etc. I hope someone can help me to solve it.
