include<stdio.h>

struct address{
        char city[20],country[20],state[20];
        };
struct customer{
        int acount;
        char name[20];
        float bal;
        struct address add;
};
void display(struct customer * ,int);
void main()
{
    int i,size;
    printf("enter the number of customers");
    scanf("%d",&size);
    struct customer cus[size];
    struct customer * c[size];
    for(i=0;i<size;i++)
    {
        printf("!");
        scanf("%s",&cus[i].name);
        printf("!");
        scanf("%d",&cus[i].acount);
        printf("!");
        scanf("%f",&cus[i].bal);
        printf("!");
        scanf("%s",&cus[i].add.city);
        printf("!");
        scanf("%s",&cus[i].add.state);
        printf("!");
        scanf("%s",&cus[i].add.country);
        c[i]=&cus[i];
    }
                void display(c,size);
}
void display(struct customer * c[],int size)
{       int i=0;
    for(i=0;i<size;i++)
    printf("name %s "/acount %d balance %f address %s %s %s"/,c[i]->name);//c[i]->acount,c[i]->bal,c[i]->add.city,c[i]->add.state,c[i]->add.country);
    //return 0;
}

Recommended Answers

All 2 Replies

You don't use & to pass characters arrays by address, they are always passed like that

example: scanf("%s",cus[i].name);

I agree With the Ancient Dragon..
"&" is used only when you are scanning for an int,float etc.
for strings and characters, there is no need of doing that!!

scanf("%s",cus[i].name); //for string
scanf("%d",&a.b); //for int || float

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.