char*f="char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c";
f is a global pointer to the char array which contains the string
"char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c"
Now in main function you are printing this string with arguments 34,f,34,10.
ASCII value of " is 34.
->So in f, the first %c is replaced by ".
->The next %s is replaced by string f.
->the second %c is replaced by " and
->last %c is replaced by backspace. The last %c is actually I feel not
required. So the code can be:
char*f="char*f=%c%s%c;main(){printf(f,34,f,34);}";main(){printf(f,34,f,34);}
I hope it helps. Try to do it manually on paper. You would be able to
understand it.
-Piyush
On Sun, Aug 28, 2011 at 11:46 AM, rahul sharma <[email protected]>wrote:
> plz expalin char*f=" "
>
>
> On Aug 28, 11:12 am, Piyush Grover <[email protected]> wrote:
> > it's a quine problem.
> >
> > char*f="char*f=%c%s%c;
> > main(){
> > printf(f,34,f,34,10);}%c";
> >
> > main()
> > {
> > printf(f,34,f,34,10);
> >
> > }
> >
> > I have used whitespaces to make it understand.
> >
> > On Sun, Aug 28, 2011 at 11:39 AM, rahul sharma <[email protected]
> >wrote:
> >
> >
> >
> >
> >
> >
> >
> > > program whose output is the program itself???????????????
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Algorithm Geeks" group.
> > > To post to this group, send email to [email protected].
> > > To unsubscribe from this group, send email to
> > > [email protected].
> > > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> 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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.