It's because "Hello, world"
is constant, so change the function to
void funcName(const char *text)
{
printf("%s\n", text);
}
String literals are constant, they are stored in a read only memory section of your program, passing the pointer without const
means that you can accidentally modify it inside the target function, if you do so, that would cause undefined behavior, and the compiler is trying to protect you from that.
Also, void main()
is not a standard compliant valid signature for main()
, you can find it in old books, previous to the standard, but now it's no longer accepted, accepted and standard signatures are
int main(void)
If you don't handle command line arguments.
int main(int argc, char **argv)
To handle argc
parameteres stored in argv
that where passed in the command line.