Peculiar behaviour with iostream namespace and isalpha function

Правка en2, от ShubhamAvasthi, 2019-12-25 19:50:40

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, 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.

Теги g++14 compiler, c++ 14, c++, g++, c++ compilers

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en5 Английский ShubhamAvasthi 2020-02-19 12:17:50 11 Tiny change: ' included namespaces/header fil' -> ' included header fil'
en4 Английский ShubhamAvasthi 2020-02-19 12:15:25 2 Tiny change: ' namespace/header file for iostr' -> ' namespaces/header files for iostr'
en3 Английский ShubhamAvasthi 2019-12-25 20:37:52 14
en2 Английский ShubhamAvasthi 2019-12-25 19:50:40 802 (published)
en1 Английский ShubhamAvasthi 2019-12-25 14:47:55 168 Initial revision (saved to drafts)