| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 959 人关注过本帖
标题:菜鸟问题,不要见笑
取消只看楼主 加入收藏
yjg19841211
Rank: 2
等 级:论坛游民
帖 子:39
专家分:41
注 册:2008-5-18
结帖率:66.67%
收藏
已结贴  问题点数:0 回复次数:3 
菜鸟问题,不要见笑
#include<iostream>
#include<string>
#include<cstring>
void strcount(char  *);
int main()
{
    using namespace std;
    string str;
    cout<<"enter...........\n";
    getline(cin,str);
    while(str!="")
    {
        strcount(&str);
        cout<<"enter!\n";
        getline(cin,str);
    }
    cout<<"*********\n";
    return 0;
}
void strcount(char *str)
{
    using namespace std;
    static int total=0;
    int count=0;
    while(*str++)
        count++;
    total+=count;
    cout<<count<<endl;
    cout<<total<<endl;
}
编译失败,错误为
 error C2664: 'strcount' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > *' to 'char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.

xiti92.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: 见笑 
2010-08-27 23:54
yjg19841211
Rank: 2
等 级:论坛游民
帖 子:39
专家分:41
注 册:2008-5-18
收藏
得分:0 
高手指点下,谢谢
2010-08-28 12:02
yjg19841211
Rank: 2
等 级:论坛游民
帖 子:39
专家分:41
注 册:2008-5-18
收藏
得分:0 
先谢谢高手指点,下班在给分哈
2010-08-28 17:02
yjg19841211
Rank: 2
等 级:论坛游民
帖 子:39
专家分:41
注 册:2008-5-18
收藏
得分:0 
...........在帮帮忙,好象不能循环输入,大家看看循环有问题没,用cin的话可以循环,但无法退出
2010-08-28 23:28
快速回复:菜鸟问题,不要见笑
数据加载中...
 
   



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

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