0

True vs 1

example: string s = "SoloLearn"; cout << (s[1]==s[3]); The output is 1, since it is correct that o==o. Just curious, would the computer ever output "True" instead of 1 (or "False" instead of 0)?

4th Aug 2020, 5:19 AM
Solus
Solus - avatar
1 Resposta
+ 2
Not until you specify so. You can use the std::boolalpha format flag in the string streams to output the textual representation of the boolean. For example, std::cout << std::boolalpha << true << std::endl; std::cout << false; // don't need boolalpha here as it has already been set for cout Outputs true false
4th Aug 2020, 5:29 AM
XXX
XXX - avatar