About 12,200,000 results
Open links in new tab
  1. How do I read an entire file into a std::string in C++?

    How do I read a file into a std::string, i.e., read the whole file at once? Text or binary mode should be specified by the caller. The solution should be standard-compliant, portable and efficient...

  2. 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?

  3. Remove spaces from std::string in C++ - Stack Overflow

    Sep 17, 2008 · What is the preferred way to remove spaces from a string in C++? I could loop through all the characters and build a new string, but is there a better way?

  4. c++ - Parsing a comma-delimited std::string - Stack Overflow

    Dec 13, 2009 · If I have a std::string containing a comma-separated list of numbers, what's the simplest way to parse out the numbers and put them in an integer array? I don't want to generalise this out …

  5. c++ - For every character in string - Stack Overflow

    Feb 24, 2012 · How would I do a for loop on every character in string in C++?

  6. Using strtok with a std::string - Stack Overflow

    There is a more elegant solution. With std::string you can use resize () to allocate a suitably large buffer, and &s [0] to get a pointer to the internal buffer. At this point many fine folks will jump and yell at the …

  7. c++ - std::wstring VS std::string - Stack Overflow

    Dec 31, 2008 · 1180 string? wstring? std::string is a basic_string templated on a char, and std::wstring on a wchar_t. char vs. wchar_t char is supposed to hold a character, usually an 8-bit character. …

  8. Initializing strings as null vs. empty string - Stack Overflow

    Feb 5, 2015 · The default construction of std::string is not ""; it is {}. Default-constructing avoids having to check the char const*, find it is an empty string, and eventually do nothing.

  9. Are the days of passing const std::string & as a parameter over?

    Apr 19, 2012 · Since the introduction of std::string_view there's never a good case for passing a reference to string. But given when you asked this question, that's probably not what you're looking for!

  10. c++ - How to append a char to a std::string? - Stack Overflow

    In addition to the others mentioned, one of the string constructors take a char and the number of repetitions for that char. So you can use that to append a single char.