yeah you can do that by opening the file and printing it but as far as I know, interviewer adds the constraint of not using the file method.
On Sun, Aug 28, 2011 at 12:35 PM, rahul sharma <rahul23111...@gmail.com>wrote: > this logic is ok...but we have pre defined everything in char f...if i > add one or two more statements then it will require corresponding > change in char *f...can i open the same file with f open n prin t it > out????? > > On Aug 28, 11:31 am, Piyush Grover <piyush4u.iit...@gmail.com> wrote: > > 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 <rahul23111...@gmail.com > >wrote: > > > > > > > > > > > > > > > > > plz expalin char*f=" " > > > > > On Aug 28, 11:12 am, Piyush Grover <piyush4u.iit...@gmail.com> 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 < > rahul23111...@gmail.com > > > >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 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. > > -- > 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.