| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1892 人关注过本帖
标题:为什么cout输出不了string字符串
取消只看楼主 加入收藏
Hlover_c
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2017-5-3
结帖率:0
收藏
已结贴  问题点数:20 回复次数:0 
为什么cout输出不了string字符串
#include "stdafx.h"
#include "iostream"
#include "iomanip"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
    string stringA = "Hello word"; //定义string类型的字符串
    cout << stringA << endl;
    string stringB(stringA);//用另一个字符串初始化字符串
    cout << "stringB= " << stringB << endl;
    string strCopy1, strCopy2;
    strCopy1 = stringA;//字符串之间的赋值运算
    cout << "strCopy1= " << strCopy1 << endl;
    strCopy2.assign(strCopy1);//将字符串赋值给本对象,相当于=操作
    strCopy2.append("programing");
    cout << "strCopy2= " << strCopy2 << endl;
    strCopy2.insert(6, "hello");
    cout << "strCopy2= " << strCopy2 << endl;
    string strADD = "in c++. ";
    stringB = stringA +  strADD;
    cout << "stringB = " << stringB << endl;

    int nLocation = stringA.find_first_of("WXYZ");
    cout << "The first position of w in stringA is " << nLocation << endl;
    int nCom = (stringB);
    cout << "compare of stringA and stringB is " << nCom << endl;

}
问题是cout<<string<<endl;//string前面的<<一直报错提示
1>          d:\app\visualstudio2013\vc\include\ostream(699): 或       “std::basic_ostream<char,std::char_traits<char>> &std::operator <<<char,std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,const char *)”
搜索更多相关主题的帖子: include 字符串 
2017-05-16 23:28
快速回复:为什么cout输出不了string字符串
数据加载中...
 
   



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

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