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

What is scanf () in c?

1170


What is the best way to store flag values in a program?

1123


I was asked to write a program in c which when executed displays how many no.of clients are connected to the server.

2401


Write a program to generate the Fibinocci Series

1299


What is malloc return c?

1080


Explain what is a 'locale'?

1127


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

1147


Is null equal to 0 in sql?

1189


What is the purpose of void pointer?

1099


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

1055


What is advantage of pointer in c?

1244


What is the use of static variable in c?

1142


please explain every phase in the "SDLC" in the dotnet.

2667


a value that does not change during program execution a) variabe b) argument c) parameter d) none

1289


Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

1991