Answers for "traverse a string character in c++"

C++
1

traverse through a string cpp

void print(const std::string &s)
{
    for (std::string::size_type i = 0; i < s.size(); i++) {
        std::cout << s[i] << ' ';
    }
}
Posted by: Guest on August-17-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 "traverse a string character in c++"

Browse Popular Code Answers by Language