沉静
  
  首页 >>  
我的日历
分类日志
友情链接
最新评论
搜索日志
访问计数
获取 RSS
我的 Blog:
youalwayscan 最新的 20 条日志
[心情留言]
[点滴积累]
[好文共赏]
[C/C+基础]
[Unix/Linux基础]
[WxWidgets]
[VC/MFC]
全站 Blog:
全站最新的 20 条日志

 
about pointers [2005-4-15]
youalwayscan 发表在 C/C+基础
Since ++ and -- are either prefix or postfix operators, other combinations of * and ++ and -- occur, although less frequently. For example,
*--p

decrements p before fetching the character that p points to. In fact, the pair of expressions
*p++ = val; /* push val onto stack */
val = *--p; /* pop top of stack into val */

are the standard idiom for pushing and popping a stack;


//////////////////////////////////////////////
Thus if the array daytab is to be passed to a function f, the declaration of f would be:

f(int daytab[2][13]) { ... }

It could also be
f(int daytab[][13]) { ... }

since the number of rows is irrelevant, or it could be
f(int (*daytab)[13]) { ... }

which says that the parameter is a pointer to an array of 13 integers. The parentheses are necessary since brackets [] have higher precedence than *. Without parentheses, the declaration
int *daytab[13]

is an array of 13 pointers to integers.
≡≡≡≡≡ 评论(共 条)我要评论