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 :: arduino buildin let 
Cpp :: c++ program to take input from user 
Cpp :: unordered_map header file c++ 
Cpp :: calculator c++ 
Cpp :: maximum int c++ 
Cpp :: prints out the elements in the array c++ 
Cpp :: c++ open all files in directory 
Cpp :: sort vector in descending order 
Cpp :: how to do nCr in c++ 
Cpp :: c++ type casting 
Cpp :: c++ vector average 
Cpp :: bubble sort in c+ 
Cpp :: c++ vector fill 
Cpp :: do while loop c++ loops continuously 
Cpp :: abs in c++ 
Cpp :: convert refference to pointer c++ 
Cpp :: check if character is uppercase c++ 
Cpp :: initialize 2d vector 
Cpp :: how to erase a certain value from a vector in C++ 
Cpp :: destructor in c++ 
Cpp :: update variable in const function C++ 
Cpp :: hello world program in c++ 
Cpp :: uses of gamma rays 
Cpp :: how to code string to int converter c++ 
Cpp :: c++ print binary treenode 
Cpp :: sorting vector elements c++ 
Cpp :: cpp when use size_t 
Cpp :: length of string in c++ 
Cpp :: remove element from vector 
Cpp :: power of a number 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =