2

i would like to understand when creating a pointer to a struct is it necessary to declare a typedef struct declaration of this nature:

what i mean is

typedef struct _something{
   int okay; 
}blah;

typedef struct _something *finger;

what is the reason that it is declared in this way , why not just declare a pointer this way

blah *arm;

so if somebody can help me understand this and which is used in which case and why and its advantages?

yukapuka
  • 87
  • 1
  • 2
  • 8
  • @MM. The first typedef already took care of that. The second typedef just hides a pointer. The question seems to be about the second one. –  May 24 '14 at 15:56
  • 1
    You can use `blah *arm;`. Where is the reference that says only the first usage is correct? – Yu Hao May 24 '14 at 15:59

1 Answers1

0

When using typedef struct _something, it means that each time you write _something it's as if your are writing struct _something. The typedef command just tells to replace what is written. So in other words, it avoids you to write struct _something.

Hoping it helps