If I am correct, the second parameter of substr()
should be the length of the substring. How about
b = a.substr(i,2);
?
More Related Contents:
- Replace part of a string with another string
- Replace substring with another substring C++
- Check if a string contains a string in C++
- How do I check if a C++ std::string starts with a certain string, and convert a substring to an int?
- C++ string::find complexity
- How to remove all substrings from a string
- Read whole ASCII file into C++ std::string [duplicate]
- How do I read an entire file into a std::string in C++?
- How can I convert a std::string to int?
- std::string formatting like sprintf
- Legality of COW std::string implementation in C++11
- C++ convert string to hexadecimal and vice versa
- printf with std::string?
- How to get rid of `deprecated conversion from string constant to ‘char*’` warnings in GCC?
- Difference between string and char[] types in C++
- how to check if given c++ string or char* contains only digits?
- What exactly is the L prefix in C++?
- How to call a function by its name (std::string) in C++?
- Set precision of std::to_string when converting floating point values [duplicate]
- Why is modifying a string through a retrieved pointer to its data not allowed?
- Similar String algorithm
- Custom manipulator for C++ iostream
- Why is there no support for concatenating std::string and std::string_view?
- What encoding does std::string.c_str() use?
- how to check string start in C++
- Padding stl strings in C++
- How to compare strings
- string::size_type instead of int
- How to convert a string of hex values to a string?
- Where are string literals stored, and can I modify them?