in scanf("%d",ptr->age) why do I need to add an & in front of ptr->age since char(ptr->gender) is not adding an &?
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#define N 5
struct person
{
char name[7];
char gender[3];
int age;
};
void input_by_adress(struct person *ptr);
void output_by_value(struct person shopper);
int main()
{
struct person buyer;
input_by_adress (&buyer);
printf("\n>> shopper info: ");
output_by_value(buyer);
return 0;
}
void input_by_adress(struct person *ptr)
{
printf("name? ");
scanf("%s", ptr->name);
printf("gender? ");
scanf("%s", ptr->gender);
printf("age? ");
scanf("%d", &ptr->age);
}
void output_by_value(struct person shopper)
{
printf("%s(%s) %d세", shopper.name, shopper.gender, shopper.age);
}
this is the code for clarifying if it is call by adress ot call by value and the part i am wondering is scanf("%d", &ptr->age);