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;
}
sanjuktamuna
0
Newbie Poster
Recommended Answers
Jump to PostYou don't use & to pass characters arrays by address, they are always passed like that
example: scanf("%s",cus[i].name);
All 2 Replies
Reply to this topic
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.