这个程序的功能是:将一个字符串中的单词分行输出。如:"what is your name"执行程序后变成
what
is
your
name
#include<iostream.h>
char *nextword(char **pp)
{
static char word[81];
while(**pp==' ')
(*pp)++;
char *pw=word;
while(**pp&&**pp!=' ')
*pw++=*(*pp)++;
*pw='\0';
return word;
}
void main()
{
char s[]="what is your name",*ps=s;
do{
cout<<nextword(&ps)<<endl;
}while(*ps);
}
这个程序不是很明白,主要是二级指针的用法,请教高手。