Posted By

vorp on 08/04/10


Tagged

format String


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

khouser


Std:string formatter


 / Published in: C++
 

  1. std::string format_arg_list(const char *fmt, va_list args)
  2. {
  3. if (!fmt) return "";
  4. int result = -1, length = 256;
  5. char *buffer = 0;
  6. while (result == -1)
  7. {
  8. if (buffer) delete [] buffer;
  9. buffer = new char [length + 1];
  10. memset(buffer, 0, length + 1);
  11. result = _vsnprintf(buffer, length, fmt, args);
  12. length *= 2;
  13. }
  14. std::string s(buffer);
  15. delete [] buffer;
  16. return s;
  17. }
  18.  
  19. std::string format(const char *fmt, ...)
  20. {
  21. va_list args;
  22. va_start(args, fmt);
  23. std::string s = format_arg_list(fmt, args);
  24. va_end(args);
  25. return s;
  26. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: louboutinshoes on August 4, 2010

just because we love christian louboutin,also we think it will made you be more sexy.IN christian louboutin sale,you can get your luxury christian louboutin shoes at cheap price.christian louboutin shoes(born 1964) is a footwear designer who launched his line of high-end women's shoes in France in 1991.trademark protection of this red sole design.cheap christian louboutin shoes,louboutin shoes,christian louboutin shoes on sale,christian louboutin sale,cheap ugg boots,ugg boots saleugg classic tall and ugg classic cardy,ugg classic short,cheap christian louboutin,christian louboutin pumps,cheap christian louboutin

You need to login to post a comment.