How do i pass a value from the main to a function which involved structure? I get always error. Please do help me to correct
Code:#include<stdio.h> void PrintPhoneX (phone x.brand, phone x.model, phone x.price){ printf("====Phone x====\n"); printf("Brand: %s\n Model: %s\n Price: %d\n",x.brand,x.model,x.price); } void PrintPhoneY (phone y.brand, phone y.model, phone y.price){ printf("====Phone y====\n"); printf("Brand: %s\n Model: %s\n Price: %d\n",y.brand,y.model,y.price); } void PrintPhoneZ (phone z.brand, phone z.model, phone z.price){ printf("====Phone z====\n"); printf("Brand: %s\n Model: %s\n Price: %d\n",z.brand,z.model,z.price); } struct phone{ char brand[10]; char model[10]; int price; }; int main (){ struct phone x; struct phone y; struct phone z; printf("====Phone x====\n"); printf("Brand:"); scanf("%s",x.brand); printf("Model:"); scanf("%s",x.model); printf("Price:"); scanf("%d",&x.price); printf("====Phone y====\n"); printf("Brand:"); scanf("%s",y.brand); printf("Model:"); scanf("%s",y.model); printf("Price:"); scanf("%d",&y.price); printf("====Phone z====\n"); printf("Brand:"); scanf("%s",z.brand); printf("Model:"); scanf("%s",z.model); printf("Price:"); scanf("%d",&z.price); PrintPhoneX (phone x.brand, phone x.model, phone x.price); PrintPhoneY (phone y.brand, phone y.model, phone y.price); PrintPhoneZ (phone z.brand, phone z.model, phone z.price); }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.