M
Michael Goldshteyn
Consider the following two lines of code, the first intended to print "Hello
world\n" and the second intended to print the character 'P' to stdout.
---
std::cout << static_cast<std:stringstream &>(std:stringstream() <<
"Hello world\n").str();
std::cout << static_cast<std:stringstream &>(std:stringstream() <<
'P').str();
---
Instead, the first line print the address of the string literal "Hello
world\n" and the second prints the ASCII value of 'P', 80.
I would like a meaningful discussion as to why this is happening. It appears
that in the first case, the const char * that is the string literal is being
interpreted in void * context and in the second case, the character is
somehow being interpreted as an int.
Thanks,
Mike
world\n" and the second intended to print the character 'P' to stdout.
---
std::cout << static_cast<std:stringstream &>(std:stringstream() <<
"Hello world\n").str();
std::cout << static_cast<std:stringstream &>(std:stringstream() <<
'P').str();
---
Instead, the first line print the address of the string literal "Hello
world\n" and the second prints the ASCII value of 'P', 80.
I would like a meaningful discussion as to why this is happening. It appears
that in the first case, the const char * that is the string literal is being
interpreted in void * context and in the second case, the character is
somehow being interpreted as an int.
Thanks,
Mike