Search
 
SCRIPT & CODE EXAMPLE
 

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

c++ loop through string

#include <iostream>

int main()
{
	std::string str = "Hello World";

	for(int i = 0; i < str.size(); i++)
	{
		std::cout << i << ". " << str.at(i) << std::endl;
	}

	return 0;
}
Comment

how to iterate throguh a string in c++

void print(const std::string &s)
{
    for (std::string::size_type i = 0; i < s.size(); i++) {
        std::cout << s[i] << ' ';
    }
}
Comment

c++ string looping

char *myStrings[] = {"This is string 1", "This is string 2", "This is string 3",
                     "This is string 4", "This is string 5", "This is string 6"
                    };

void setup() {
  Serial.begin(9600);
}

void loop() {
  for (int i = 0; i < 6; i++) {
    Serial.println(myStrings[i]);
    delay(500);
  }
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: how to scan array in c++ 
Cpp :: create file c++ 
Cpp :: overload stream insert cpp 
Cpp :: c++ foreach 
Cpp :: c++ first letter of string 
Cpp :: how to easily trim a str in c++ 
Cpp :: strlen in c++ 
Cpp :: increment c++ 
Cpp :: destructor in c++ 
Cpp :: iterate vector in reverse c++ 
Cpp :: c++ vector size 
Cpp :: delete from front in vector c++ 
Cpp :: tolower funciton in cpp 
Cpp :: run cmd command c++ 
Cpp :: ue4 float to fstring 
Cpp :: c++ code for bubble sort 
Cpp :: who to include a library c++ 
Cpp :: c++ string to int 
Cpp :: how to read files in c++ 
Cpp :: remove space in string c++ 
Cpp :: how to compile opencv c++ in ubuntu 
Cpp :: implementing split function in c++ 
Cpp :: c++ check if string is isogram 
Cpp :: cpp while 
Cpp :: iterate vector c++ 
Cpp :: cpp lambda function 
Cpp :: c++ split string by space into array 
Cpp :: c++ write to csv file append 
Cpp :: Youtube backlink generator tool 
Cpp :: number of nodes of bst cpp 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =