[algogeeks] Please explain the output

2011-06-23 Thread vaibhav shukla
#includestdio.h #define power(a) #a int main() { printf(%d,*power(432)); return 0; } ans is 52 on gcc. Explain plss -- best wishes!! Vaibhav Shukla DU-MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Please explain the output

2011-06-23 Thread Shachindra A C
#includestdio.h #define power(a) #a int main() { printf(%d,*power(432)); return 0; } the printf statement, after preprocessing, will look like printf(%d,*432); so, when u print the value at the first position of the string, 52, which is the ascii value of 4, will be printed. On Thu, Jun 23,

Re: [algogeeks] Please explain the output

2011-06-23 Thread Piyush Sinha
printf(%d,*power(432)) will expand as *printf(%d, *432)* 432 represents here a string and *432 is pointing to the first string literal i.e 4 whose ascii value is 52..hence the output is 52 On Thu, Jun 23, 2011 at 4:02 PM, Shachindra A C sachindr...@gmail.comwrote: #includestdio.h #define

Re: [algogeeks] Please explain the output

2011-06-23 Thread vaibhav shukla
hmm i got it.thnx On Thu, Jun 23, 2011 at 4:05 PM, Piyush Sinha ecstasy.piy...@gmail.comwrote: printf(%d,*power(432)) will expand as *printf(%d, *432)* 432 represents here a string and *432 is pointing to the first string literal i.e 4 whose ascii value is 52..hence the output is 52

Re: [algogeeks] Please explain the output

2011-06-23 Thread rajeev bharshetty
#a is the replacement sequence which is substituted in the printf statement The statements #define power(a) #a printf(%d,power(a)); is substituted as printf(%d,a); it is replaced with the string literal a . then *power(a) is converted as value at that string literal address. Hope this solves

Re: [algogeeks] please explain the output

2011-04-09 Thread ArPiT BhAtNaGaR
COOL BRO THIS IS A GOOD SOLN On Tue, Apr 5, 2011 at 4:10 PM, Azhar Hussain azhar...@gmail.com wrote: Few Important things about macros, before I explain the output 1. Macros are replaced in passes. 2. Macros are not recursive. regarding the output remember the rule for expansion A

Re: [algogeeks] please explain the output

2011-04-09 Thread Prakash D IT @ CEG
nice explanation -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit

Re: [algogeeks] please explain the output

2011-04-09 Thread Pratik Kathalkar
u can see the pre-processed file using gcc -E prog_name.cand @ bottom u can see what actually the code is doing. On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote: #includestdio.h #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() {

Re: [algogeeks] please explain the output

2011-04-09 Thread ArPiT BhAtNaGaR
thx pratik On Sat, Apr 9, 2011 at 8:13 PM, Pratik Kathalkar dancewithpra...@gmail.comwrote: u can see the pre-processed file using gcc -E prog_name.cand @ bottom u can see what actually the code is doing. On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote:

[algogeeks] please explain the output

2011-04-05 Thread Arvind
#includestdio.h #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() { printf(%s,g(f(1,2))); printf(\t%s,h(f(1,2))); return 0; } i have run this program in gcc compiler and getting : f(1,2) 12 as output. can anyone explain the reason for getting this output? -- You received this

Re: [algogeeks] please explain the output

2011-04-05 Thread Vandana Bachani
Hi Arvind, These are preprocessor specific operators. Check out http://msdn.microsoft.com/en-us/library/wy090hkc(v=vs.80).aspx -Vandana On Tue, Apr 5, 2011 at 12:45 PM, Arvind akk5...@gmail.com wrote: #includestdio.h #define f(a,b) a##b #define g(a) #a #define h(a) g(a) int main() {

Re: [algogeeks] please explain the output

2011-04-05 Thread Azhar Hussain
Few Important things about macros, before I explain the output 1. Macros are replaced in passes. 2. Macros are not recursive. regarding the output remember the rule for expansion A parameter in the replacement list, *UNLESS* preceded by a # or ## preprocessing token or followed by a ##

[algogeeks] please explain the output

2010-11-05 Thread ANUJ KUMAR
#includestdio.h int main() { printf(anuj,kumar); return 0; } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] please explain the output

2010-11-05 Thread Piyush
*The prototype of printf is* *int printf(const char ***format**, ...);* * * *Thus it takes a string and then variable number of arguments.* * * *Every argument passed after (char *format)string is to resolve the% inside the string (which is passed as the first argument)* * * *Thus anuj will be