开发者

typedef in c and type equivalence

If I do this:

typedef int x[10];
x a;

Is it开发者_如何学运维 same as: int a[10]; ?


Yes.    


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜