Hello,
Since printf specifies that the char pointer passed to it is of type const char, is itCode:ex1 ----------------------------------- char *name[] = "brian"; printf("Hello %s.\n", name); ex2 ----------------------------------- char *name[] = "brian"; printf("Hello %s.\n", (const char*) name); ----------------------------------
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:
most people don't put the (void) in front of printf's, etc. What is the purpose ofCode:(void) printf("Hello\n"); or (void) fprintf(stderr, "error\n");
people writing code in this way? Does is make the program any safer?
thanks![]()



LinkBack URL
About LinkBacks



