My main function is as follows:
int main(int argc, char const *argv[])
{
huffenc(argv[1]);
return 0;
}
The compiler returns the warning:
huffenc.c:76: warning: passing argument 1 of ‘huffenc’ discards qualifiers from pointer target type
For reference, huffenc
takes a char*
input, and the function is executed, with the sample input "senselessness" via ./huffenc senselessness
What could this warning mean?
It means that you're passing a
const
argument to a function which takes a non-const
argument, which is potentially bad for obvious reasons.huffenc
probably doesn't need a non-const
argument, so it should take aconst char*
. However, your definition ofmain
is non-standard.The C99 standard Section 5.1.2.2.1 (Program startup) states:
And goes on to say...