这个练习涉及到了字符串、循环、指针和指针增量的使用。首先,假设已经定义了下面的函数:
#include <stdio.h> char *pr (char *str) { char *pc; pc = str; while (*pc) putchar (*pc++); do { putchar (*--pc); } while (pc - str); return (pc); }
考虑下面的函数调用:
x = pr ("Ho Ho Ho! ");
a. 会打印出什么?
b. x是什么类型?
c. x值等于多少?
d. 表达式*--pc是什么意思?它和--*pc有什么不同?
e. 如果用*pc--代替*--pc,会打印出什么?
f.两个while表达式有什么判断功能?
g. 如果pr()函数的参数是一个空字符串,会有什么结果?
h. 怎样调用函数pr()才能实现所示的功能?