looking at a character in a string c++ code example
Example 1: index string c++
#include <string>
#include <iostream>
int main(){
//index string by using brackets []
std::string string = "Hello, World!";
//assign variable to string index
char stringindex = string[2];
}
Example 2: c++ string contains
if (string1.find(string2) != std::string::npos) {
std::cout << "found!" << '\n';
}