首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

代码有异常吗

2012-07-16 
代码有错误吗?#includeiostreamusing namespace stdint main(){char s[]what is your name,*pssdo

代码有错误吗?
#include<iostream>
using namespace std;
int main()
{
  char s[]=
"what is your name",
*ps=s;
do 

cout<<nextword(&ps)<<endl;

while (*ps);
return 0;
}
char *nextword(char **pp)
{
static char word[81];
while(**pp==' ')(*pp)++;
char *pw=word;
while(**pp && **p!=' ')
*pw++=*(*pp)++;
*pw='\0';
return word;
}

[解决办法]
#include<iostream>
using namespace std;

char *nextword(char **pp)
{
static char word[81];
while(**pp==' ')(*pp)++;
char *pw=word;
while(**pp && **pp!=' ')
*pw++=*(*pp)++;
*pw='\0';
return word;
}

int main()
{
char s[]="what is your name";
char *ps=s;

do{
cout<<nextword(&ps)<<endl;
}while (*ps);

return 0;
}
你把上面的代码拷过去试试~出错的原因你自己看看吧~

热点排行