yup........thnx On Sun, Jul 31, 2011 at 12:28 PM, rajeev bharshetty <rajeevr...@gmail.com>wrote:
> scanf returns the number of characters scanned as input,in here the scanf > statement gets placed at getchar and hence since it accepts 1 character 'c' > will print the value 1. > > #ifdef getchar checks for whether getchar is defined if defined it > undefines it as #undef > else > it #define getchar as scanf // this statement actually runs . > hence the output is 1 , characters accepted by the scanf . > > Hope you understood > > > On Sun, Jul 31, 2011 at 12:00 PM, SHIVAM AGRAWAL <shivi...@gmail.com>wrote: > >> i got it........ >> >> >> On Sun, Jul 31, 2011 at 11:08 AM, SHIVAM AGRAWAL <shivi...@gmail.com>wrote: >> >>> plz xplain y it is printing zero ...means how dis prgrm is wrkng step by >>> step >>> >>> >>> On Sun, Jul 31, 2011 at 11:03 AM, rajeev bharshetty < >>> rajeevr...@gmail.com> wrote: >>> >>>> *#include<stdio.h>* >>>> *#ifdef getchar* >>>> *#undef getchar* >>>> *#else* >>>> *#define getchar scanf("%c",&ch);* >>>> *#endif* >>>> *main()* >>>> *{* >>>> * char ch;* >>>> * int c;* >>>> * c=getchar;* >>>> * printf("%d",c);* >>>> *}* >>>> >>>> This above code works as expected .... >>>> >>>> On Sun, Jul 31, 2011 at 11:02 AM, rajeev bharshetty < >>>> rajeevr...@gmail.com> wrote: >>>> >>>>> Above Program is showing error on gcc compiler >>>>> >>>>> *ms52.c: In function ‘main’:* >>>>> *ms52.c:11:19: error: expected expression before ‘)’ token* >>>>> >>>>> Check the code ... >>>>> >>>>> On Sun, Jul 31, 2011 at 10:59 AM, SHIVAM AGRAWAL >>>>> <shivi...@gmail.com>wrote: >>>>> >>>>>> can any xplain me d output and working of dis code....... >>>>>> #include<stdio.h> >>>>>> #ifdef getchar >>>>>> #undef getchar >>>>>> #else >>>>>> #define getchar scanf("%c",ch); >>>>>> #endif >>>>>> main() >>>>>> { >>>>>> char ch; >>>>>> int c; >>>>>> c=getchar(); >>>>>> printf("%d",c); >>>>>> } >>>>>> >>>>>> -- >>>>>> 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 this group at >>>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Regards >>>>> Rajeev N B <http://www.opensourcemania.co.cc> >>>>> >>>>> "*Winners Don't do Different things , they do things Differently"* >>>>> >>>>> >>>> >>>> >>>> -- >>>> Regards >>>> Rajeev N B <http://www.opensourcemania.co.cc> >>>> >>>> "*Winners Don't do Different things , they do things Differently"* >>>> >>>> -- >>>> 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 this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >> -- >> 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 this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Regards > Rajeev N B <http://www.opensourcemania.co.cc> > > "*Winners Don't do Different things , they do things Differently"* > > -- > 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 this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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 this group at http://groups.google.com/group/algogeeks?hl=en.