Hello,
Code:
ex1
-----------------------------------
char *name[] = "brian";
printf("Hello %s.\n", name);
ex2
-----------------------------------
char *name[] = "brian";
printf("Hello %s.\n", (const char*) name);
----------------------------------
Since printf specifies that the char pointer passed to it is of type const char, is it
a good idea to explicilty cast (I never see anyone do this) or am I correct in assuming
that it is automagically cast to const when handed to printf()?
Also, In alot of code I see this:
Code:
(void) printf("Hello\n");
or
(void) fprintf(stderr, "error\n");
most people don't put the (void) in front of printf's, etc. What is the purpose of
people writing code in this way? Does is make the program any safer?
thanks