| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 584 人关注过本帖
标题:编程错误
只看楼主 加入收藏
醒山
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:9
帖 子:463
专家分:2071
注 册:2015-5-25
结帖率:88.89%
收藏
已结贴  问题点数:100 回复次数:5 
编程错误
编程错误提示如下:错误    1    error C2664: “std::basic_istream<char,std::char_traits<char>> &std::basic_istream<char,std::char_traits<char>>::get(std::basic_streambuf<char,std::char_traits<char>> &,_Elem)”: 无法将参数 1 从“char”转换为“char *”    c:\users\think\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp    10    1    ConsoleApplication1
错误    2    error C2664: “void strcount(const char *)”: 无法将参数 1 从“char”转换为“const char *”    c:\users\think\documents\visual studio 2013\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp    16    1    ConsoleApplication1
    4    IntelliSense:  没有与参数列表匹配的 重载函数 "std::basic_istream<_Elem, _Traits>::get [其中 _Elem=char, _Traits=std::char_traits<char>]" 实例
            参数类型为:  (char, const int)
            对象类型是:  std::istream    c:\Users\THINK\Documents\Visual Studio 2013\Projects\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.cpp    10    5    ConsoleApplication1
应该怎么改??大家帮忙看看
#include<iostream>
const int ArSize = 10;
void strcount(const char * str);
int main()
{
    using namespace std;
    char input(ArSize);
    char next;
    cout << "Enter a line:\n";
    cin.get(input, ArSize);
    while (cin)
    {
        cin.get(next);
        while (next != '\n')
            cin.get(next);
        strcount(input);
        cout << "Enter next line (empty line to quit):\n";
        cin.get(input, ArSize);
    }
    cout << "Bye\n";
    return 0;
}
void strcount(const char * str)
{
    using namespace std;
    static int total = 0;
    int count = 0;
    cout << "\"" << str << "\"contains";
    while (*str++)
        count++;
    total += count;
    cout << count << " characters\n";
    cout << total << " characters total\n";
}
搜索更多相关主题的帖子: visual documents 
2015-11-06 20:38
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:50 
input的char,而strcount()函數要求的參數是const char*,你自己看看調用類型對不對?再説了,你創建的是C++/CLI項目,卻全是本地C++模式。

授人以渔,不授人以鱼。
2015-11-06 21:35
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:50 
进来看看

DO IT YOURSELF !
2015-11-10 13:09
醒山
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:9
帖 子:463
专家分:2071
注 册:2015-5-25
收藏
得分:0 
本地c++模式?
2015-11-11 20:10
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:0 
vc++有兩種程序模式,一是傳統的本地代碼C++,另一是托管代碼C++,後者即基於.net的C++/CLI程序。從你創建的項目名稱ConsoleApplication看,這是C++/CLI項目,亦即你選了CLR模板。C++/CLI使用.net的類庫,其庫函數形式與C#、是一致的,因爲所有.net的程序,到最後的可執行程序,實際上沒有區別,反匯編是分不出原本用什麽語言寫的。本地C++代碼,又稱非托管代碼。

授人以渔,不授人以鱼。
2015-11-12 03:11
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:528
帖 子:9007
专家分:53942
注 册:2011-1-18
收藏
得分:0 
char input(ArSize); 改为 char input[ArSize];
2015-11-12 08:22
快速回复:编程错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015235 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved