设为首页 加入收藏

TOP

2.3 Compound Types (7)
2013-10-07 16:18:27 来源: 作者: 【 】 浏览:83
Tags:2.3 Compound Types

EXERCISES SECTION 2.3.2

Exercise 2.18: Write code to change the value of a pointer. Write code to change the value to which the pointer points.

Exercise 2.19: Explain the key differences between pointers and references.

Exercise 2.20: What does the following program do

  1. int i = 42;   
  2. int *p1 = &i;   
  3. *p1 = *p1 * *p1;  

Exercise 2.21: Explain each of the following definitions. Indicate whether any are illegal and, if so, why.

  1. int i = 0;  

(a) double* dp = &i; (b) int *ip = i; (c) int *p = &i;

Exercise 2.22: Assuming p is a pointer to int, explain the following code:

  1. if (p) // ...   
  2. if (*p) // ...  

Exercise 2.23: Given a pointer p, can you determinewhether p points to a valid object If so, how If not, why not

Exercise 2.24: Why is the initialization of p legal but that of lp illegal

  1. int i = 42; void *p = &i; long *lp = &i;  

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇2.3 Compound Types (6) 下一篇2.3 Compound Types (8)

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·用 Python 进行数据 (2025-12-25 15:49:09)
·如何学习Python数据 (2025-12-25 15:49:07)
·利用Python进行数据 (2025-12-25 15:49:04)
·Java 学习线路图是怎 (2025-12-25 15:19:15)
·关于 Java 学习,有 (2025-12-25 15:19:12)