Answers for "how to get char from string in c++"

C++
0

c++ get character from string

#include <iostream>
#include <string>

int main() {
    std::string myStr = "test string";

    for (int i = 0; i < myStr.length(); ++i) {
        std::cout << myStr.at(i) << std::endl;
    }

    return 0;
}
Posted by: Guest on March-29-2021
1

c++ char to string

#include <iostream>
using namespace std;

int main()
{
  char c = 'l';
  string str;
  str.push_back(c);
}
Posted by: Guest on June-20-2020

Code answers related to "how to get char from string in c++"

Browse Popular Code Answers by Language