Hello all,
Can somebody explain why strchr is declared the way it is? Here is
the declaration:
char *strchr(const char *s, int c);
Mainly I do not understand why the second parameter has the 'int'
type. From my knowledge it is not even portable. On a machine where
'char' has the same size as an 'int' and where 'char' has the same
behaviour as an 'unsigned char' the following piece of code could not
work as expected:
{
char c;
char *p;
/* some statements here initializing c */
p = strchr(my_string, c);
}
I am not a portability expert, so probably I am wrong. But having the
second parameter of 'char' type is less confusing and does not change
the behaviour at all.
thx
cristi