Boost logo

Boost Users :

From: Lynn Allan (l_d_allan_at_[hidden])
Date: 2006-04-10 10:14:55


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_at_[hidden]>
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.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net