I am trying to printf the values in the structs from 2 arrays but the output gets very wierd and I dont know why.
this is whats get outputed: c123 6545645 bvabc123 vabc123 abc132
this should be outpued: Johan 47 Car Volvo abc123
whats wrong?
struct person{
char name;
int age;
};
typedef struct person p;
struct vehicle{
char type;
char brand;
char regn;
char owner;
};
typedef struct vehicle v;
int main(){
p owner[1];
v Vehicle[1];
for(int i=0; i<1;i++){
printf("Name\n");
scanf("%s",&owner[i].name);
printf("Age\n");
scanf("%d",&owner[i].age);
printf("Type\n");
scanf("%s",&Vehicle[i].type);
printf("Brand\n");
scanf("%s",&Vehicle[i].brand);
printf("regn\n");
scanf("%s",&Vehicle[i].regn);
}
for(int j=0; j<1; j++){
printf("%s\n", &owner[j].name);
printf("%d\n", &owner[j].age);
printf("%s\n", &Vehicle[j].type);
printf("%s\n", &Vehicle[j].brand);
printf("%s\n", &Vehicle[j].regn);
}
}