how to find last character of string in c++
#include <iostream>
#include <string>
using namespace std;
int main() {
string str = "Hello, World!";
char lastChar = str[str.length() - 1];
cout << "The last character of the string is: " << lastChar << endl;
return 0;
}