Like this:
std::string s("Test string");
std::string::iterator it = s.begin();
//Use the iterator...
++it;
//...
std::cout << "index is: " << std::distance(s.begin(), it) << std::endl;
Related Contents:
- Why use string::iterator rather than index? [duplicate]
- Static constant string (class member)
- Convert a String In C++ To Upper Case
- Why is conversion from string constant to ‘char*’ valid in C but invalid in C++
- How do I read an entire file into a std::string in C++?
- Replace part of a string with another string
- How to append a char to a std::string?
- C++ Convert string (or char*) to wstring (or wchar_t*)
- How do you reverse a string in place in C or C++?
- Deleting elements from std::set while iterating
- How to change string into QString?
- What does iterator->second mean?
- C++ deprecated conversion from string constant to ‘char*’
- what is the difference between const_iterator and iterator? [duplicate]
- Creating my own Iterators
- Iterating C++ vector from the end to the beginning
- Is there a simple way to convert C++ enum to string?
- How to convert a number to string and vice versa in C++
- What are the mechanics of short string optimization in libc++?
- Convert float to string with precision & number of decimal digits specified?
- What is the lifetime of the result of std::string::c_str()?
- Sorting Characters Of A C++ String
- How can I extract the file name and extension from a path in C++
- Why am I getting string does not name a type Error?
- What is an iterator’s default value?
- Pointer to incomplete class type is not allowed
- std::string vs string in c++ [duplicate]
- How to reverse an std::string? [duplicate]
- Difference between string.empty and string[0] == ‘\0’
- how portable is end iterator decrement?
- What’s faster, iterating an STL vector with vector::iterator or with at()?
- When did C++ compilers start considering more than two hex digits in string literal character escapes?
- c++11 foreach syntax and custom iterator
- Should custom containers have free begin/end functions?
- C++ string to double conversion
- std::stringstream vs std::string for concatenating many strings
- Is there a C++ iterator that can iterate over a file line by line?
- converting a variable name to a string in C++
- variable or field declared void
- Returning an empty string : efficient way in c++
- How can I create a string from a single character?
- Is string.c_str() deallocation necessary?
- How to retrieve value type from iterator in C++?
- “to_string” isn’t a member of “std”?
- How do I replace all instances of a string with another string?
- writing directly to std::string internal buffers
- Making a user-defined class std::to_string-able
- Press Enter to Continue
- How can std::vector access elements with huge gaps between them?
- How to return a std::string.c_str()