Computer problems,Computer help
*AX SOFT>>>Programming & Design

Array of Structures?


for example I have an array of structures

typedef struct{
int nSeeds;
float fHeight;
}structFlower

typedef stuctFlower arrFlower[5];

can I do this? (provided they have initial values)

main()
{
arrFlower aRose, aOrchid;

aRose[1]=aOrchid[0];
}

will aRose[1].nSeeds be equal to aOrchid[0].nSeeds?

Yes. Contrary to what the previous responder said, structure assignment, as shown in your example, is valid in ANSI C.

No, it's not possible in C. You have to assign all of the struct members individually. In C++ (even though this is off topic), you could overload the assignment operator on a class to allow this.

However, in C, you could work around this by using a memset() of the first struct to the second struct. I wouldn't recommend it. Better to make a function to copy the first to the second if your goal is readability.

void flowerCopy(structFlower *from, structFlower *to) {

to->nSeeds = from->nSeeds;
to->fHeight = from->fHeight;

return;
}

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Music for my website?

    I love notepad. Good job! If you want people to be able to download them, then all you need is a link. Use anchor tags, and upload your files as you please. If you are asking what you need ...

  • Free Clothes On Zwinky?

    to unlock every thing you have to press f2

    ...
  • Html big doubt?

    Your syntax is incorrect and it's recognizing your HTML as just plain text. Make sure you have all of your tags closed (<HTML>,<HEAD>,<BODY>,etc) and everything is symmetric....

  • Java prablom?

    There is a big difference between "if" and "else if". An if statement will always be executed where as, an "else if" will only be executed when the if returns false. F...

  • What does "line b problem parsing XML: "null" is null or not and object". mean?

    It's a bug in their JavaScript code, nothing you can do apart from report it to AT&T support. It's their problem, not yours.

    ...
  • How to add a chess board in blogspot. i downloaded pgn viewer then wat?

    Try this: ...

  • How to make high quality wallpapers?

    You got it right, Adobe Photoshop is a good software for this.

    ...
  • JAVA what should i do????

    There is nothing wrong with your code. I added the else statement... else System.out.println("speed up slow-poke"); and it worked for all entered values. I'm not sure what&#...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster