user188276
user188276

Reputation:

typedef in c and type equivalence

If I do this:

typedef int x[10];
x a;

Is it same as: int a[10]; ?

Upvotes: 1

Views: 791

Answers (3)

Roman Nikitchenko
Roman Nikitchenko

Reputation: 13046

Yes if we speak about syntax. But think about this:

typedef int MyType[5];

/* Some code, large enough fragment */

int func (MyType var)
{
  /* Something that changes */
  return 0;
}

If you see only func() declaration you can think it receives var by value so any change inside function is local. But as actually MyType is array which is pointer changing var inside func() you can change actual caller's variable.

So speaking about concept this is not the same.

Upvotes: 1

Ravindra S
Ravindra S

Reputation: 6442

Yes its same. If you want to learn more, go here.

Upvotes: 3

unwind
unwind

Reputation: 399969

Yes.    

Upvotes: 4

Related Questions