Tuesday, August 16, 2005

Something basic abt declaring structures

struct a_1{
int a;
char b[10];
};

The above does not declare any variable. It only associates the structure's type with a_1.
struct a_1 A;

This is the one that actually does the job of creating a structure named A with the type struct a_1 .

It can also be done using the foll statement:
struct {
int a;
char b[10];
} A;

This obviates the use of the second statement (struct a_1 A;) .
If I need to declare a structure pointer the foll shud be done.

struct {
int a;
char b[10];
} *A;

OR

typedef struct {
int a;
char b[10];
} A_t;
A_t *A;

Dont forget to malloc A .

(Taken from a mail that i sent to myself on 20/05/2005)

0 Comments:

Post a Comment

<< Home