and why?
I usally use sprintf with a charcter array, what is a comparable function in the string class?
Printable View
and why?
I usally use sprintf with a charcter array, what is a comparable function in the string class?
It is my understanding that there is a sprintf for use in C++ also, but its in stdio.h
and it has the same function as with C
here is a site:
http://www.cplusplus.com/ref/cstdio/sprintf.html
If you want to stay to a portable way of coding, std::string is the way to go. I don't know what it's formatting powers are though.
If you are using Windows and MFC, CString is your friend. It has a Format function that takes exactly the same parameters like printf.
Use stringstreams for formatting with the standard string class. They use the '<<' operator so you don't have to specify format arguments.