标题:编程错误
取消只看楼主
醒山
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:9
帖 子:463
专家分:2071
注 册:2015-5-25
结帖率:88.89%
已结贴  问题点数:100 回复次数:1 
编程错误
编程错误提示如下:错误    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
醒山
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:9
帖 子:463
专家分:2071
注 册:2015-5-25
得分:0 
本地c++模式?
2015-11-11 20:10



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-458957-1-1.html




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

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