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 / yogesh bansal

#include <stdio.h>

int main()
{
FILE *file;
char filename[]="outputsourcecode.c";
char str[125];
file=fopen(filename,"r");
if(file == NULL)
{
printf("cannot open the file");
exit(1);
}
while(!feof(file))
{
if(fgets(str,125,file))
{
printf("%s", str);
}
}
return 0;
}

this is a working code.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of the function in c?

1006


#include { printf("Hello"); } how compile time affects when we add additional header file .

1877


What is structure in c explain with example?

1148


What is meant by int main ()?

1186


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1985


Which header file is used for clrscr?

1046


What is the difference between procedural and functional programming?

1060


write a program to copy the string using switch case?

2881


Which is an example of a structural homology?

1306


What are the 5 types of inheritance in c ++?

1011


How are variables declared in c?

1076


Difference between constant pointer and pointer to a constant.

1120


Write a program to know whether the input number is an armstrong number.

1102


Is Exception handling possible in c language?

2035


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

1059