std::string::c_str() and temporaries

前端 未结 3 1724
独厮守ぢ
独厮守ぢ 2020-11-28 07:22

Is the following C++ code well-formed:

void consumer(char const* p)
{
  std::printf(\"%s\", p);
}

std::string random_string_generator()
{
  // returns a ran         


        
3条回答
  •  感动是毒
    2020-11-28 08:01

    The temporary returned by the function random_string_generator() can be used in consumer() function safely.

提交回复
热议问题