Answers for "how to traverse in the characters of string array in c++"

C++
1

loop through char in string c++

std::string s("Hello world");

for (char & c : s)
{
    std::cout << "One character: " << c << "\n";
    c = '*';
}
Posted by: Guest on May-23-2021
0

traverse string in cpp

// C++ program to demonstrate getline() function
 
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
    string str;
 
    cout << "Please enter your name: \n";
    getline(cin, str);
    cout << "Hello, " << str
         << " welcome to GfG !\n";
 
    return 0;
}
Posted by: Guest on January-30-2022

Code answers related to "how to traverse in the characters of string array in c++"

Browse Popular Code Answers by Language