mercredi 28 mars 2018

How correctly do I need to press the void pointer?

void func(const char* str)
{
void *s = &str;
std::cout << *(char**)s << std::endl; // it's correct
std::cout << (char*)s << std::endl; // it's not correct
}

int main()
{
char *str = "hello world";
func(str);

return 0;
}

Aucun commentaire:

Enregistrer un commentaire