indexing strings in c++ code example
Example 1: index string c++
#include
#include
int main(){
//index string by using brackets []
std::string string = "Hello, World!";
//assign variable to string index
char stringindex = string[2];
}
Example 2: indexing strings in c++
// string::operator[]
#include
#include
int main ()
{
std::string str ("Test string");
for (int i=0; i