the scope of this function is to get inputs and save into a file . simple right ? but i cannot find the file after i input whith the console . please help me !
void addpassenger()
{
int size = sizeof(struct passenger);
struct passenger newPassenger;
printf("Name: ");
gets(newPassenger.name);
printf("Surname: ");
gets(newPassenger.surname);
printf("ID card No: ");
gets(newPassenger.idCard);
printf("Nationality: ");
gets(newPassenger.Nationality);
printf("Telephone/Mobile: ");
scanf("%d",&newPassenger.phone);
FILE *pt =fopen("passenger.dat","a");
fwrite(&newPassenger,size,1,pt);
fclose(pt);
}
fwrite - second and third arguments you have passed are wrong ..
Second Argument is size - Size in bytes of each element to be written. size_t is an unsigned integral type.
Third argument is count - Number of elements, each one with a size of size bytes. size_t is an unsigned integral type
So your arguments should be