Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to iterate in string in c++

#include<iostream>
using namespace std;
main() {
   string my_str = "Hello World";
   for(int i = 0; i<my_str.length(); i++) {
      cout << my_str.at(i) << endl; //get character at position i
   }
}
Source by www.tutorialspoint.com #
 
PREVIOUS NEXT
Tagged: #iterate #string
ADD COMMENT
Topic
Name
7+9 =