标题:为什么会有一段空白在输出字符串前面?
取消只看楼主
ClarenceC
Rank: 2
等 级:论坛游民
帖 子:54
专家分:18
注 册:2014-1-10
结帖率:87.5%
已结贴  问题点数:16 回复次数:0 
为什么会有一段空白在输出字符串前面?
fstream executed;
    string file_name("D:\d.txt"); //content is "hello nihao zhongxiaogang clarence hello world"
    executed.open(file_name.c_str());
    vector<string> executed_vec(10);
    set<string> iset;
    string word;
    while(executed>>word)
    {
        executed_vec.push_back(word);
        iset.insert(word);
    }
    for(vector<string>::const_iterator vecp=executed_vec.begin();vecp!=executed_vec.end();++vecp)
    {
        cout<<*vecp<<" ";//why this consequence has a blank stretch in front of string
    }
    cout<<endl;
    for(set<string>::const_iterator setp=iset.begin();setp!=iset.end();++setp)
    {
        cout<<*setp<<" ";//why this has no blank stretch
    }
    cout<<endl;
    return 0;
结果是:[local]1[/local]  为什么会有一段空白在第一排字符串之前呢?
不好意思各位,我不知道怎么没法加上图片。我描述一下:在控制台输出结果中会有一段空白在“hello nihao zhongxiaogang clarence hello world"前,
如   "          (前面是一段空白)hello nihao zhongxiaogang clarence hello world"

[ 本帖最后由 ClarenceC 于 2014-3-8 19:06 编辑 ]
搜索更多相关主题的帖子: world nihao hello 字符串 content 
2014-03-08 19:01



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




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

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