Why does using '\n\n' print a number rather than giving two newlines? One '\n' prints me a newline, using double quotes like "\n\n" gives two newlines but '\n\n' gives me numbers rather than the newlines, why is this?
I dont think this is code specific, I think it is something to do with c++ but the code I discovered it with, I pasted below.
#include <iostream>
//#include "person.h"
using std::cout;
using std::cin;
template <class temp>
temp testMax(temp A, temp B)
{
temp result;
result = (A > B) ? A : B;
return result;
}
int main()
{
cout << '\n\n';
cout << testMax(9, 11);
return 0;
}
This is a malformed program. Improper C++. It's behaviour that the C++ standard doesn't specify and leaves up to the compiler to do whatever it likes.
You have indicated ONE character, with the ' ' , but then written TWO characters.
What happens when you present more than one character in this manner is implementation specific. It is expected that if you do this, it's because you have some special compiler or some special knowledge and you know all about it and you really do want some kind of weird mutant multi-character character constant.
If in your case you get a number, well, your compiler is allowed to do whatever it likes and that's what it chose to do.