|
|
|
|
|
by pqomdv
4106 days ago
|
|
We are talking about C and not a specific compiler, so there are a lot of mistakes in your comment. char * * is a pointer to a pointer to a char and nothing else, it might be a NULL terminated array or not at all. C cares about types. Casting a pointer to an incompatible type or reinterpreting through an incompatible pointer is not defined in C( undefined behavior ). Pointers of different types are allowed to have different sizes. sizeof( char* ) == sizeof( char* * ) is not guaranteed in C. Also any program whose main is not int main( void ) or int main( int , char* * ) will result in undefined behavior. All of this is in the latest standard. Both, segfaulting or running completely normally can be a result of undefined behavior. That is why we really like to avoid it in C. Thus your advice is really not good for a modern C. |
|
> sizeof( char* ) == sizeof( char* * )
True, I forgot that different architectures/compilers can produce different pointer sizes. Thanks!