#include#include int main() { std::string str = "Hello World"; char c = str.at(0); std::cout << c; // Output: H return 0; }
#includeThis example demonstrates how we can access the 7th character (which is 'W') using the "at" function in C++ string. In conclusion, the "at" function in C++ string is useful when you want to access a specific character at a particular index. It is part of the "#include int main() { std::string str = "Hello World"; char c = str.at(6); std::cout << c; // Output: W return 0; }