0

I'm new to c++ , I'm working on a project that uses std::string and then converts that string to char* to be used in functions that are going to be exported.

However, I'm getting an empty string when I debug it.

#include <iostream>
#include <string>

void fun(char* &x, char* &y)
{
    std::string tmp = "hello"; 
    std::string temp = "world";
    x = &tmp[0];
    y = &temp[0];

}
int main()
{
    char* x;
    char* y;

    fun(x, y);
}

enter image description here enter image description here

Best regards.

user3374161
  • 301
  • 3
  • 14

0 Answers0