How do you write a program which produces its own source
code as its output?
Answers were Sorted based on User's Feedback
Answer / vivek
printitself.c
#include <stdio.h>
int main()
{
char ch;
FILE *file;
file=fopen("printitself.c","r");
while((ch=fgetc(file))!=EOF)
printf("%c",ch);
return 0;
}
| Is This Answer Correct ? | 19 Yes | 2 No |
Answer / abhinav gupta
Try to google....quine Problem...
one solution is
main(){char *c="main(){char
*c=%c%s%c;printf(c,34,c,34);}";printf(c,34,c,34);}
| Is This Answer Correct ? | 3 Yes | 0 No |
Answer / sharath
can we use system() to print source code of a file??
if yes please with an example.
also explain how to execute please please
i am in an urgent need.
please
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / abhishek
#include <stdio.h>
static char prog[] = "#include <stdio.h>%c%cstatic char prog[] = %c%s%c;%c%cint main(void)%c{%c printf(prog, 10, 10, 34, prog, 34, 10, 10, 10, 10, 10, 10, 10);%c return 0;%c}%c";
int main(void)
{
printf(prog, 10, 10, 34, prog, 34, 10, 10, 10, 10, 10, 10, 10);
return 0;
}
| Is This Answer Correct ? | 1 Yes | 2 No |
difference of two no's with out using - operator
Explain built-in function?
"C" language developed by "Dennis Ritchie" at AT & T. his remarks are a) too general, too abstract b) could deal with only specific problems c) lost generality of BCPL and B restored d) no remarks
What does %c do in c?
1. Write a C program to count the number of occurrence of a specific word in the given strings. (for e.g. Find how many times the word “live” comes in the sentence “Dream as if you’ll live forever, live as if you’ll die today ”)
DIFFERNCE BETWEEN THE C++ AND C LANGUAGE?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
What are c identifiers?
Explain how do you use a pointer to a function?
What are the differences between new and malloc in C?
what is the difference between #include<> and #include”…”?
How can I manipulate individual bits?