
This seems to work ok using boost::format: #include <iostream> #include <boost/format.hpp> void main(void) { std::string myBuf10("1234567890"); std::cout << "Put truncated: " << boost::format("%|.5s|\n") % myBuf10 << " part of " << myBuf10 << std::endl; } ----- Original Message ----- From: "Paul Giaccone" <paulg@cinesite.co.uk> Newsgroups: gmane.comp.lib.boost.user Sent: Monday, April 10, 2006 2:55 AM Subject: Re: [string] HowTo: equiv of printf("%.5s\n",myBuf10);
Lynn Allan wrote:
I've been puzzled about doing the equivalent of: printf("%.5s\n", myBuf10); and also: printf("%.*s\n", 5, myBuf10); Note: newbie with std::string ... using Microsoft vc7.1 compiler
Thanks.
string isn't a Boost library. You're unlikely to get any help here. Try posting to comp.lang.c++ on Google Groups.