Subj : Re: Questions...??? To : borland.public.cpp.borlandcpp From : Ed Mulroy Date : Fri Sep 09 2005 04:34 pm The function printf accepts a variable length argument list. It knows how many arguments and what to do with them because the first argument is a char* style string which contains format specifications. The format specification for a character is %c and for a char* style string is %s. Once the second, extra opening parentheses is removed from the printf statement, the program consists of c a string containing format specifications decimal integer 34, a '\"' character which matches the first %c in the string a copy of the string itself which matches the %s in the string another 34 34 works as '\"' because in C and C++ characters as merely very short integers. The numeric value for a character is a legal equivalent to its character representation. The reason it was done that way probably was as a puzzle. .. Ed > mujeebrm wrote in message > news:4321c777@newsgroups.borland.com... > Hi, > > my name is mujeeb. > > i have some questions about below mentioned program... > > main(){ char *c="main(){char *c=%c%s%c;printf(c,34,c,34);}" > printf((c,34,c,34);} > > *c is pointer to char sing-dim array > > 34 is ascii for " quotes " > > then how printf(c,34,c,34); prints the whole program as it is or > replicates it when > > printf's declaration says that > > printf(format specifiers, arg list); > > but in this statement we are only doing this printf(c,34,c,34); why > > can any plz decipher this to me or provide reasons or techniques behind > all this... .