I can\'t figure out why I get this warning from clang
by myself:
function_prototype_const_modifier.c:13:8: warning: initializing \'char *\' with
Because type of L.H.S is char *
and type of R.H.S is const char *
.
The reason is exactly as what error says:
function_prototype_const_modifier.c:13:8: warning: initializing 'char *' with an expression of type 'const char *' discards qualifiers
The statement allows you to discard the const
qualifier and it allows to modify the pointed string through ptr1
and ptr2
and hence the compiler complains.