Top "Stdstring" questions

std::string is the C++ standard library's byte-based "string" type, defined in the <string> header.

std::string formatting like sprintf

I have to format std::string with sprintf and send it into file stream. How can I do this?

c++ string formatting stdstring c++-standard-library
What's the best way to trim std::string?

I'm currently using the following code to right-trim all the std::strings in my programs: std::string s; s.erase(…

c++ trim stdstring
How to concatenate a std::string and an int?

I thought this would be really simple but it's presenting some difficulties. If I have std::string name = "John"; int …

c++ int concatenation stdstring
convert a char* to std::string

I need to use an std::string to store data retrieved by fgets(). To do this I need to convert …

c++ stdstring
How to replace all occurrences of a character in string?

What is the effective way to replace all occurrences of a character with another character in std::string?

c++ algorithm str-replace stdstring
How do you append an int to a string in C++?

int i = 4; string text = "Player "; cout << (text + i); I'd like it to print Player 4. The above is obviously …

c++ int stdstring
How to get the number of characters in a std::string?

How should I get the number of characters in a string in C++?

c++ string stdstring string-length
Alternative to itoa() for converting integer to string C++?

I was wondering if there was an alternative to itoa() for converting an integer to a string because when I …

c++ integer stdstring itoa
Concatenating strings doesn't work as expected

I know it is a common issue, but looking for references and other material I don't find a clear answer …

c++ operator-keyword string-concatenation stdstring standard-library
How do you convert CString and std::string std::wstring to each other?

CString is quite handy, while std::string is more compatible with STL container. I am using hash_map. However, hash_…

c++ mfc c-strings stdstring