get first char in string c++ code example
Example 1: find character in string c++
auto char_to_find = 'a'
if (str.find(char_to_find) != std::string::npos) {
// character found
}
Example 2: c++ first letter of string
// string::at
#include <iostream>
#include <string>
int main ()
{
std::string str ("Test string");
for (unsigned i=0; i<str.length(); ++i)
{
std::cout << str.at(i);
}
return 0;
}