home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: alt.hackers
- Path: sparky!uunet!caen!positron
- From: positron@engin.umich.edu (Jonathan Scott Haas)
- Subject: Self Printing Program, revisited
- Message-ID: <9lm-wK-@engin.umich.edu>
- Date: Thu, 03 Sep 92 23:54:41 EDT
- Organization: University of Michigan Engineering, Ann Arbor
- Approved: Yep.
- Nntp-Posting-Host: myrrh.engin.umich.edu
- Lines: 35
-
- Awhile back, there was talk about how to write a program whose
- output would be the program itself. Here's my program, written
- in C, but I think perhaps it "cheats" a bit.
-
- --clip here---------------------------------------------
-
- /*
- * This is a program that should print itself. However, some
- * people might view its algorithm as cheating.
- *
- * Jonathan S. Haas, 3 Sep 92 11:49 pm
- *
- */
-
- #include <stdio.h>
-
- int main(void)
- {
- char in[100];
- FILE *readme;
-
- readme=fopen(__FILE__,"r");
- while(!feof(readme)) {
- fgets(in,99,readme);
- printf("%s",in);
- }
- fclose(readme);
- }
-
-
- --
- __/\__ Jonathan S. Haas | Jake liked his women the way he liked
- \ / University of Michigan | his kiwi fruit: sweet yet tart, firm-
- /_ _\ positron@engin.umich.edu | fleshed yet yielding to the touch, and
- \/ | covered with short brown fuzzy hair.
-