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

声明调用函数时出现异常

2012-02-06 
声明调用函数时出现错误!#includestdio.hmain(){charstr[100]gets(str)maxlong(str)puts(str)}maxlo

声明调用函数时出现错误!
#include   <stdio.h>
main(){
 
char   str[100];
gets(str);
maxlong(str);
 
puts(str);

}
maxlong(char   *str){
int   ml,i,count,wz;
count=0;
wz=0;
ml=0;
for   (i=0;str[i]!= '\0 ';i++)
if   (str[i]!= '   ')  
      {  
        count++;
  if(str[i+1]== '\0 '&&ml <count){
  ml=count;wz=i-count+1;}
      }
else{
if   (ml <count){
  ml=count;wz=i-count;}
count=0;
}

for   (i=0;str[i+wz]!= '   '&&str[i+wz]!= '\0 ';i++)
str[i]=str[i+wz];
str[i]= '\0 ';
}
/*看看上面函数,为什么在程序第三行中声明void   maxlong(char)就会出错,
出错提示:第6行       tpye   mismatch   in   parameter   1   in   call   to   'maxlong '   in   function   main
                  第11行     type   mismatch   in   redeclaration

[解决办法]
maxlong(char *str){...}
==》
void maxlong(char *str){...}

void maxlong(char)
==》
void maxlong(char *)

热点排行