Using Struct

Hi, really silly question!
I have defined a sample struct:-
typedef struct record
{
int one;
int two;
int three;
} record;

And i'm trying to access it by:- using record.one = 1;
But i'm getting an error of 'record' was not declared in this scope.
Even though the decloration was in the setup section!
Any ideas what i have done wrong??

MaF

You haven't declared a variable of type "record", you've declared a datatype called "record".

Structs are generally declared more like this:

struct record
{
    int one;
    int two;
    int three;
};

typedef struct record Record;

Then, in your code, you can have this:

Record aRec;
aRec.one = 12;

There's nothing wrong with declaring it

 typedef struct 
  {
      int one;
      int two;
      int three;
  } record, *precord;

which also handily defines the datatype "record" and a pointer to that datatype "precord".

There's nothing wrong with declaring it

No, except for readability. I have an easier time understanding my way than I do understanding your way. I know that the compiler has no such issue.

Thanks Guys!
It works nicely now!!

MaF