one more method : use system funtion .
eg system("cat filename") //system funtion executes the commandOn Sun, Aug 28, 2011 at 1:51 PM, UTKARSH SRIVASTAV <[email protected]>wrote: > good logic > > > On Sun, Aug 28, 2011 at 12:14 AM, Piyush Grover <[email protected] > > wrote: > >> 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 >> <[email protected]>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 <[email protected]> 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 < >>> [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. >>> >>> >> -- >> 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. >> > > > > -- > *UTKARSH SRIVASTAV > CSE-3 > B-Tech 3rd Year > @MNNIT ALLAHABAD* > > -- > 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.
