Re: struct problems



On 20 Jan, 00:51, Richard <rgrd...@xxxxxxxxx> wrote:
Keith Thompson <ks...@xxxxxxx> writes:
Mark Wooding <m...@xxxxxxxxxxxxxxxx> writes:
"Bill Cunningham" <nos...@xxxxxxxxxxxxx> writes:
[...]
struct cat kitty1,kitty2;

kitty1={"striper","striped"};
kitty2={"spook","black"};

And this is the actual problem.  You're presumably trying to initialize
these structure variables.  You want

struct cat
  kitty1 = { "striper", "striped" },
  kitty2 = { "spook",   "black"   };

As a matter of style, I wouldn't declare multiple objects in a single
line line that.  I'd write:

    struct cat kitty1 = { "striper", "striped" };
    struct cat kitty2 = { "spook",   "black"   };

[...]

His style is far nicer IMO. Why specify the type twice?
Localisation. Compact. Clean.

int* pi, pj;

the person who wrote that might think pj was an int*.
If you want compact use a typedef.

Cat kitty1;
Cat kitty2;

--
Nick Keighley

Every sentence I utter must be understood not as an affirmation,
but as a question.
Niels Bohr

.



Relevant Pages