Codeforces Round 1133 (Div. 1, Div. 2) is coming soon! Register here. ×
Peculiar behaviour with iostream namespace and isalpha function
Difference between en1 and en2, changed 802 character(s)
↵
~~~~~↵
#include <iostream>↵
using namespace std;↵
↵
int main()↵
{↵
cerr<<isalpha('a');↵
}↵
~~~~~↵
↵
↵
I tested the following code with three different compilers and saw some peculiar results. First of all, I am not sure why the program compiles (no errors with isalpha) indicating that cctype/ctype.h is being automatically included allowing the compilation of the program.↵
↵
As far as I know and according to [cplusplus.com](http://www.cplusplus.com/reference/iostream/), neither cctype namespace nor ctype.h header file is amongst the automatically included namespace/header file for iostream. Also, iostream does not inherit from cctype/ctype.h.↵
↵
~~~~~↵
#include <iostream>↵
using namespace std;↵
↵
int main()↵
{↵
cerr<<isalpha('a');↵
}↵
~~~~~↵
↵
On my local machine with MinGW (32 bit), it prints 2.↵
↵
On Codeforces compiler, it prints nothing.↵
↵
On ideone, it prints 1024.↵
↵
All the above compilations were done for C++14.↵
↵
It would be great if someone could share the reason for this behaviour.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English ShubhamAvasthi 2020-02-19 12:17:50 11 Tiny change: ' included namespaces/header fil' -> ' included header fil'
en4 English ShubhamAvasthi 2020-02-19 12:15:25 2 Tiny change: ' namespace/header file for iostr' -> ' namespaces/header files for iostr'
en3 English ShubhamAvasthi 2019-12-25 20:37:52 14
en2 English ShubhamAvasthi 2019-12-25 19:50:40 802 (published)
en1 English ShubhamAvasthi 2019-12-25 14:47:55 168 Initial revision (saved to drafts)