赞
踩
练习11-1
- /*---将代码清单进行修改---*/
-
- #include <stdio.h>
-
- int main(void)
- {
- char *p = "123";
- printf("p = \"%s\"\n", p);
- p = "456" + 1;
- printf("p = \"%s\"\n", p);
-
- return 0;
- }
练习11-2
- /*---将代码中的常量用程序计算出来---*/
-
- #include <stdio.h>
-
- int count(const char *c) {
- int n = 0;
- while (*c++)
- n++;
- return n;
- }
-
- int main(void)
- {
- int i;
- char a[][5] = {"LISP", "C", "Ada"};
- char *p[] = {"PAUL", "X", "MAC"};
-
- for (i = 0; i < count(a); i++)
- printf("a[%d] = \"%s\"\n", i, a[i]);
-
- for (i = 0; i < count(*p); i++)
- printf("p[%d] = \"%s\"\n", i, p[i]);
-
- return 0;
- }
练习11-3
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。