Search
 
SCRIPT & CODE EXAMPLE
 

CPP

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];
  
}
Comment

indexing strings in c++

// 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;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: deque c++ 
Cpp :: are strings mutable in c++ 
Cpp :: find index of element in array c++ 
Cpp :: convert unsigned long to string c++ 
Cpp :: c++ print 3d cube 
Cpp :: c++ hello world 
Cpp :: how to reverse a vector 
Cpp :: hello world in c++ 
Cpp :: c++ encapsulation 
Cpp :: cannot jump from switch statement to this case label c++ 
Cpp :: cout c++ 
Cpp :: prisma client 
Cpp :: abs in cpp 
Cpp :: bee 1002 solution 
Cpp :: function in c++ 
Cpp :: c++ filesystem read directory 
Cpp :: substr in cpp 
Cpp :: sum of row s2 d array c++ 
Cpp :: Convert a hexadecimal number into decimal c++ 
Cpp :: sort c++ 
Cpp :: double to float c++ 
Cpp :: inserting element in vector in C++ 
Cpp :: SUMOFPROD2 solution 
Cpp :: factorial of large number 
Cpp :: how to convert string to int in c++ 
Cpp :: c++ print 
Cpp :: c++ find index of all occurrences in string 
Cpp :: c++ program to convert celsius to kelvin 
Cpp :: Syntax for C++ Operator Overloading 
Cpp :: power in c++ 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =