[LC++]strings and numbers

Vincent Penquerc'h Vincent.Penquerch at artworks.co.uk
Thu Jul 4 02:01:08 UTC 2002


> I'm getting a little tired of using atoi and sprintf to 
> convert between 
> numbers and strings. I'm using STL strings, and I was thinking that 
> perhaps it have some build in methods that can do the trick smothly?

In case it doesn't exist (it sure does however :)), you can
factor code:


string i2s(int n)
{
  char s[64];
  snprintf(s,sizeof(s),"%d",n);
  return stirng(s);
}


void main()
{
  string s(i2s(5));
}


-- 
Vincent Penquerc'h
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.linux.org.au/pipermail/tuxcpprogramming/attachments/20020704/74b7a751/attachment.htm 


More information about the tuxCPProgramming mailing list