F
Frederick Gotham
I gather that, rather than the C++ Standard defining the functionality of
the Standard Library features which it has in common with C, it makes
reference to a C Standard which defines their functionality.
Is the C Standard in question C89 (or C90 as some call it)?
Does the C++ Standard make any changes to the C Standard Library which it
inherits? For example, in C, the "toupper" function takes an argument of
int, and the value passed to it must be within range of an unsigned char.
Are things the same in C++? If so, the following program can invoke
undefined behaviour:
#include <cctype>
int main()
{
toupper('a');
}
Why? Because 'a' might be a negative number.
A better example would be the use of extended characters, which are far
more likely to be a negative number:
toupper( 'German sharp s' );
To remedy this, many C programmers always cast the argument:
toupper( (unsigned char)'German sharp s' );
the Standard Library features which it has in common with C, it makes
reference to a C Standard which defines their functionality.
Is the C Standard in question C89 (or C90 as some call it)?
Does the C++ Standard make any changes to the C Standard Library which it
inherits? For example, in C, the "toupper" function takes an argument of
int, and the value passed to it must be within range of an unsigned char.
Are things the same in C++? If so, the following program can invoke
undefined behaviour:
#include <cctype>
int main()
{
toupper('a');
}
Why? Because 'a' might be a negative number.
A better example would be the use of extended characters, which are far
more likely to be a negative number:
toupper( 'German sharp s' );
To remedy this, many C programmers always cast the argument:
toupper( (unsigned char)'German sharp s' );