开发者

how to print data inside a char pointer (c++)?

开发者 https://www.devze.com 2023-02-02 14:47 出处:网络
I have a function(const char * data) { //how to print the data which is inside the data } when I debug I see only the address. If I pri开发者_运维百科nt (*data) nothing is printed.

I have a

function(const char * data)
{
//how to print the data which is inside the data
}

when I debug I see only the address. If I pri开发者_运维百科nt (*data) nothing is printed.

Any idea?


#include <iostream>

void function(const char * data)
{
    std::cout << data;
}


printf("%s\n", data) works for me.


std::cout << std::string(data);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号