I have the following enum and struct:
enum Destination { unknown = 0, hosok, parlament, var };
struct Client
{
char name[30];
char email[30];
char phone_num[11];
int client_num;
enum Destination destination;
struct tm registration_date;
};
When I invoke the following method, it reads the first struct and print it's name, then I get a segmentation fault.
void list_clientss()
{
FILE *f = fopen(filename, "r");
if( f == NULL )
{
perror("Error");
}
struct Client client;
while( !feof( f ) )
{
fread(&client, sizeof(struct Client), sizeof(struct Client), f);
printf("Name: %s\n", client.name);
}
fclose(f);
}
What did I wrong?