为什么会有一段空白在输出字符串前面?
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 编辑 ]