24小时热门版块排行榜    

查看: 371  |  回复: 2

zyj8119

木虫 (著名写手)

[交流] 【求助】一个C++程序,改来改去就是有一个错误,找不出来了 已有1人参与

CODE:
#include
#include


int  select(int n,char a[],int b[])
{     int i=0,count=0;
      while(i                   while(!(a[i]>='0'||a[i]<='9')){
                          i++;
                          if(i>=n||!a[i])
                                  break;
                  }
                  if(i>=n)break;
                  b[count]=a[i]-'0';i++;
                  while(a[i]>='0'&&a[i]<='9'){
                          b[count]=10*b[count]+(a[i]-'0');
                          i++;
                  }
                  count++;
          }
                  return count;
}

          void main(void)
          {    int count;
               char a[100];
                   int b[50];
                   cout<<"输入字符串,长度小于100:\n";
                   cin.getline(a,100);
                   count=select(a,strlen(a),b);
                   cout<<"count="<                    for(int i=0;i                            cout<                    cout<           }

--------------------Configuration: hggg - Win32 Debug--------------------
Compiling...
hggg.cpp
C:\Program Files\Microsoft Visual Studio\Common\MSDev98\My Projects\hggg.cpp(30) : error C2664: 'select' : cannot convert parameter 1 from 'char [100]' to 'int'
        This conversion requires a reinterpret_cast, a C-style cast or function-style cast
Error executing cl.exe.

hggg.obj - 1 error(s), 0 warning(s)
使用VC编译的。
回复此楼
好好学习,天天向上。
已阅   关注TA 给TA发消息 送TA红花 TA的回帖

yalefield

金虫 (文坛精英)

老汉一枚

★ ★
zyj8119(金币+10):谢谢老汉,C++水平太烂,哎。。。 2010-11-05 09:19:06
ajian04(金币+2):谢谢交流~ 2010-11-05 17:44:12
是不是又偷看老TAN的书了?

(1)select自身
CODE:
int  select(int n,char *a,int *b)

(2)对select的调用
CODE:
count=select(strlen(a),a,b);

参数的次序也错了
2楼2010-11-05 09:06:09
已阅   关注TA 给TA发消息 送TA红花 TA的回帖

zyj8119

木虫 (著名写手)

引用回帖:
Originally posted by yalefield at 2010-11-05 09:06:09:
是不是又偷看老TAN的书了?

(1)select自身
CODE:
int  select(int n,char *a,int *b)

(2)对select的调用
CODE:
count=select(strlen(a),a,b);

参数的次序也错了

此帖结帖。
好好学习,天天向上。
3楼2010-11-05 09:19:23
已阅   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zyj8119 的主题更新
信息提示
请填处理意见