Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do you write a program which produces its own source
code as its output?

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you determine the length of a string value that was stored in a variable?

1126


What is LINKED LIST? How can you access the last element in a linked list?

1075


What is an lvalue?

1066


Why static variable is used in c?

1038


a c code by using memory allocation for add ,multiply of sprase matrixes

2807


Is main is user defined function?

1156


What is data structure in c language?

1115


What is difference between class and structure?

1117


Distinguish between actual and formal arguments.

1087


How macro execution is faster than function ?

1200


What are header files in c?

1083


What is the use of define in c?

1064


Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.

1977


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

1100


How can I run c program?

1180