I want to select the first 8 characters of a string using C++. Right now I create a temporary string which is 8 characters long, and fill it with the first 8 characters of anot
Just use std::string::substr:
std::string::substr
std::string str = "123456789abc"; std::string first_eight = str.substr(0, 8);