B
baibaichen
hi i want to output strings with indent space, the code looks like:
std::set<std::string> files;
std::set<std::string> iterator b = files.begin();
std::set<std::string> iterator e = files.end();
for (b; b!=e b++)
std::cout << '\t' << *b << std::endl;
the another way is :
string add_indent(const string& str)
{
return '\t' + str;
}
transform(files.begin(),files.end(),ostream_iterator<string>(cout,"\n"),add_indent);
which is better? and is there better way to add indent space?
thanks
std::set<std::string> files;
std::set<std::string> iterator b = files.begin();
std::set<std::string> iterator e = files.end();
for (b; b!=e b++)
std::cout << '\t' << *b << std::endl;
the another way is :
string add_indent(const string& str)
{
return '\t' + str;
}
transform(files.begin(),files.end(),ostream_iterator<string>(cout,"\n"),add_indent);
which is better? and is there better way to add indent space?
thanks