check if a variable is tring c++
#include <iostream>
#include <string>
int main() {
// Declare a variable
auto variable = "Hello, World!";
// Check if the variable is a string
if (std::string str = dynamic_cast<std::string>(&variable)) {
// The variable is a string
std::cout << "The variable is a string: " << *str << std::endl;
} else {
// The variable is not a string
std::cout << "The variable is not a string." << std::endl;
}
return 0;
}