各位仁兄帮帮我,这个编程哪错了?c

王朝知道·作者佚名  2012-09-27
窄屏简体版  字體: |||超大  
 
分類: 電腦/網絡 >> 程序設計 >> 其他編程語言
 
問題描述:

#include<stdio.h>

#include<string.h>

#include<ctype.h>

#include<conio.h>

char xx[80];

char delwords[5][21]={"a","is","in","the","an"};

void ReverseWord(void)

{ int j,k,len;

char *p,word[21];

char buf[80], str[80];

memset(buf,0,80);

memset(str,0,80);

p=xx[20];

j=0;

memset(word,0,21);

while(*p){

if(isalpha(*p))

{word[j++]=*p++;

if(*p)continue;

}

for(k=0;k<5;k++)

{if(stricmp(word,delwords[k])==0)

break;

}

if(k==5)

{len=strlen(word);

if(len>=5)

{if(islower(word[0]))

word[0]=toupper(word[0]);

}

strcpy(buf,word);

strcat(buf," ");

strcat(buf,str);

strcpy(str,buf);

}

j=0;

memset(word,0,21);

while(*p&&(!isalpha(*p)))

p++;

}

strcpy(xx[80],str);

}

void main()

{char xx[80]={"today is sunny you know?"};

ReverseWord();

printf("%s",xx[80]);

}

參考答案:

两个错误:

1、p=xx[20];

p是指针,xx[20]是字符,不可赋值。

2、strcpy(xx[80],str);

strcpy需要字符数组或指针为参数,而xx[80]不是

小贴士:① 若网友所发内容与教科书相悖,请以教科书为准;② 若网友所发内容与科学常识、官方权威机构相悖,请以后者为准;③ 若网友所发内容不正确或者违背公序良俗,右下举报/纠错。
 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航