Thursday, July 30, 2009

C Structures. Help please.?

Normal structures is simple, but this is a nested structure and im clueless on how to do the following, anyone can give me a hand. Yes im newbie but im willing to learn on this.








struct customer{


char lastName[15];


char firstName[15];


int customerNumber;





struct{


char phoneNumber[11];


char address[50];


char city[15];


char state[3];


char zipCode[6];


}personal;





}customerRecord;





Write a separate expression that can be used to access the structure members in each of the following parts:





a. Member lastName of structure customer Record.





b. Member firstName of structure customer Record.





c. Member customerNumber of structure customer Record





d. Member phoneNumber of member personal of structure customer Record.





e. Member address of member personal of structure customer Record.





f. Member city of member personal of structure customer Record.





g. Member state of member personal of structure customer Record.








Help would be greatly appreciated.

C Structures. Help please.?
All structures in C are top-level concepts, thus you can't have an embedded structure with the personal information like you have in your example. You need to have:





struct personal {


char phoneNumber[11];


char address[50];


char city[15];


char state[3];


char zipCode[6];


};





struct customer{


char lastName[15];


char firstName[15];


int customerNumber;


struct personal personalInfo;


}customerRecord;





customerRecord.lastName = "Bush";


customerRecord.firsName = "George";


customerRecord.customerNumer = "1";


customerRecord.personalInfo.phoneNumbe...





...


No comments:

Post a Comment