delete last char of string C++
#include <iostream>
#include <string>
int main() {
std::string str = "Hello, World!"; // Step 1: Declare and initialize a string variable
if (!str.empty()) { // Step 2: Check if the string is not empty
str.pop_back(); // Step 3: Remove the last character of the string
}
std::cout << "Modified String: " << str << std::endl; // Step 4: Print the modified string
return 0; // Step 5: Return 0 to indicate successful completion
}