程序的功能是:调用Input函数读入一个长度不超过81的字符串,字符串中只含字母和空格,遇到读满或者回车结束读入字符,空格用于分隔单词。请将字符串中用空格分隔的单词在屏幕上输出来。 要求用指针完成函数中各参数的传递与访问,自定义函数头和函数体中不得出现数组下标形式的表示法。
void Input ( char *str ) {
char x;
x = getchar();
int i = 1;
while(x != '\n' && i < 81) {
if ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z') || x == ' ') {
str[i-1] = x;
i++;
}
x = getchar();
}
*(str+i) = '\0';
}
int Split_Count ( char *str,char **pStr ) {
int count = 0;
while(*str) {
if (*str != ' ') {
*(pStr+count) = str;
count++;
}
while(*str) {
if (*str == ' ') {
*str = '\0';
break;
}
str++;
}
str++;
}
return count;
}