quine_program_c

A quine is a computer program (a kind of metaprogram) whose output and source
code are identical. As a challenge or for fun, some programmers try to write the shortest quine in a given programming language.
The operation that consist of simply opening the source file and displaying it is considered cheating. More generally, a program that uses any data entry cannot be considered a valid quine. A trivial solution is a program whose source code is empty. Indeed, the execution of such a program produces for most languages no output, that is to say the source code of the program.

test using the following commands :

First

  • description : When executed, the program display on the standard output an output identical to the source code of the file used to compile the program.
  • compile and run : gcc -Wall -Wextra -Werror first.c; ./a.out > tmp; diff tmp first.c

Second

  • description : When executed, the program writes in a file named Grace_kid.c the source code of the file used to compile the program (it doesn't containe a main function, Three defines only)
  • compile and run : clear;gcc -Wall -Wextra -Werror second.c; ./a.out; diff second.c second_kid.c

Third

  • description : When executed the program writes in a file named Sully_X.c. The X will be an interger given in the source. Once the file is created, the program compiles this file and then runs the new program (which will have the name of its source file). Stopping the program depends on the file name : the resulting program will be executed only if the integer X is greater than or equal to 0.
  • compile and run : clear; gcc -Wall -Wextra -Werror third.c -o Sully; ./Sully; diff third.c Sully_0.c ; diff third.c Sully_1.c; diff third.c Sully_2.c; diff third.c Sully_3.c; diff third.c Sully_4.c