I have a method that has a const void* input parameter. How can I cout
the string passed in?
For example:
#include <iostream>
void print_string_from_pointer(const void *buf) {
std::cout << SOMETHING_GOES_HERE << std::endl;
}
int main () {
std::string x("XYZ");
print_string_from_pointer(&x);
return 0;
}
should print "XYZ"
Aucun commentaire:
Enregistrer un commentaire