Horje
c++ string element access Code Example
index string c++
#include <string>
#include <iostream>

int main(){
  //index string by using brackets []
  std::string string = "Hello, World!";
  //assign variable to string index
  char stringindex = string[2];
  
}
c++ string element access
// string::operator[]
#include <iostream>
#include <string>

int main ()
{
  std::string str ("Test string");
  for (int i=0; i<str.length(); ++i)
  {
    std::cout << str[i];
  }
  return 0;
}




Cpp

Related
indexing strings in c++ Code Example indexing strings in c++ Code Example
how to store pair in min heap in c++ Code Example how to store pair in min heap in c++ Code Example
c++ length of char* Code Example c++ length of char* Code Example
c++ check palindrome Code Example c++ check palindrome Code Example
how to take space separated input in c++ Code Example how to take space separated input in c++ Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7