Search
 
SCRIPT & CODE EXAMPLE
 

CPP

how to traverse string like array in cpp

// C++ program to implement
// the above approach
  
#include <bits/stdc++.h>
using namespace std;
  
// Function to traverse the string and
// print the characters of the string
void TraverseString(string &str, int N)
{ 
    // Traverse the string
    for (int i = 0; i < N; i++) {
  
        // Print current character
        cout<< str[i]<< " ";
    }
      
}
  
// Driver Code
int main()
{
    string str = "GeeksforGeeks";
      
    // Stores length of the string
    int N = str.length();
  
    TraverseString(str, N);
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: Error: C++14 standard requested but CXX14 is not defined 
Cpp :: 1491. Average Salary Excluding the Minimum and Maximum Salary leetcode solution in c++ 
Cpp :: 16630147 
Cpp :: c++ hsl to rgb integer 
Cpp :: cast unreal c++ 
Cpp :: Problems in your to-do list codechef solution in c++ 
Cpp :: cpp full form 
Cpp :: can derived class access base class non-static members without object of the base class 
Cpp :: c++ switch integer 
Cpp :: sort 3 numbers using swap cpp 
Cpp :: operator using 
Cpp :: bitmap rotate 90 deg 
Cpp :: cast c++ 
Cpp :: frc limelight tracking 
Cpp :: cicli informatica c++ 
Cpp :: inversed priority queue 
Cpp :: c++ map value int to string 
Cpp :: how to run a cpp file in visual studio 
Cpp :: c++ remove last element from array 
Cpp :: c++ variables 
Cpp :: how to change the type of something in c++ 
Cpp :: c++ filesystem remove file 
Cpp :: c++ influenced 
C :: c bold text 
C :: factorial in c 
C :: shuffle function in c 
C :: how to search in a file in c 
C :: remove element from np array 
C :: print 0 1 2 3 4 in c 
C :: nested switch case in c 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =