How to print data inside char pointer (C ++)?

I have

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

When I debug, I only see the address. If I print (* data) nothing is printed.

Any idea?

+4
source share
3 answers
 #include <iostream> void function(const char * data) { std::cout << data; } 
+8
source

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

+3
source
 std::cout << std::string(data); 
-1
source

Source: https://habr.com/ru/post/1334494/


All Articles