Bill said:
What I'm really wanting to know I guess is how structs work and how to use
them.
They work the same way ints work. They're just types, that's all.
I used the GUID example.
For example.
typedef struct A{
int a;
double b;}/* sometimes a term */ ;
This is a syntax error.
typedef struct A{
int a;
double b;} A;
would not be a syntax error, however. Here is the typedef again, this time
on a single line:
typedef struct A{ int a; double b;} A;
Here it is again, perhaps slightly less confusingly:
typedef struct A_tag { int a; double b;} A;
There are two parts here, which I'll separate out vertically for you:
xxxxxxx struct A_tag { int a; double b;} xx
typedef xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx A;
There's the typedef (something-as) A, and there's the struct definition.
Put them together, and you are defining A as an alias for struct A_tag.
and I've seen struct A without the typedef.
What's the difference with and w/o the typedef?
typedef creates a new synonym for an existing type. So, once the compiler
has seen the above example, you can use A wherever you would previously
have used struct A_tag - if you wish. To confuse matters, the tag is
allowed to be the same as the new type.
The structs hold data I
can see. How are they called?
You don't call a struct. It's just a bunch of data.
Yes. That data can, in fact, include pointers to functions, but they're just
data too.
This and pointers are the major sticking points for me with C.
Get a better C book, then.
And when
there are bunches of parenthesis such as (((((*c))))))). That's confusing.
This reduces to *c)) which (on its own) is a syntax error. Don't be confused
by syntax errors. Just fix them.