Sometimes I think that a foreign language should be required for programmers.

Think about what you are telling the computer to do:
*xyz.abcarray[0] = 255; // this causes the errror

You are telling the computer to dereference the entire expression, xyz.abcarray[0] -- specifically the integer value already contained in abcarray[0] -- and to store a value of 255 at that location being pointed to. It cannot recognize xyz as a struct because xyz was declared as a pointer to a struct, but not as a struct itself.

In order to tell it that you want to dereference xyz and access the element abcarray[0] within it, you could change that line to:
(*xyz).abcarray[0] = 255;
Now, that way it knows that you are talking about dereferencing xyz, not the entire left expression.

I mention that construction above because it can be handy at times in C++ (especially in MFC), but a far better and much more conventional way of expressing it would be:
xyz->abcarray[0] = 255;

Thanks. Would you believe I already thought of that but used { } instead of ( )? :rolleyes: You can tell that I am not use to programming in C...

Just tested it, it works. Thanks a million.

Originally posted by dwise1_aol Think about what you are telling the computer to do:
*xyz.abcarray[0] = 255; // this causes the errror

You are telling the computer to dereference the entire expression, xyz.abcarray[0] -- specifically the integer value already contained in abcarray[0] -- and to store a value of 255 at that location being pointed to.

Ouch. That could be deadly to my server. I ran this program about 10 times too with that bad code. [edit: nevermind, I just remembered that it did not compile with the bad code, so when I was running it it was an early copy of the program.]

Some languages, like Ada, are written to protect the programmer from himself (actually, Ada was somewhat paranoid about that, as I recall). Then there's C, written by programmers to do what they wanted to do, that figures that you know what you're doing and if you wrote it that way, that's what you wanted to have happen.

There was a classic C book, which I unfortunately did not get, called something like "Shooting Yourself in the Foot with Your Own Rope". It spawned a serious of computer jokes which described how various languages would accomplish the same effect; eg, BASIC: you shoot your foot repeatedly with a water pistol until it gets waterlogged. One page with such a collection is at http://burks.brighton.ac.uk/burks/language/shoot.htm .

It's all part of learning and using C. And the main reason I can spot many mistakes is because I've committed them myself.