I am trying to create a copy of a std::string to a char*. This is my function and its seen result:
void main()
{
std::string test1;
std::cout << "Enter Data1" << std::endl;
std::cin >> test1;
char* test2;
test2 = (char*)test1.c_str();
std::cout << "test1: "<< &test1 << std::endl;
std::cout << "test2: "<< &test2 << std::endl;
}
Enter Data1
Check
test1: 0x7fff81d26900
test2: 0x7fff81d26908
I am unsure if a copy has been created or both of them are pointing to the same location. How to confirm this?