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

Why is not a pointer null after calling free?

1072


how many types of operators are include in c language a) 4 b) 6 c) 8 d) 12

1131


How do we open a binary file in Read/Write mode in C?

1275


Define Spanning-Tree Protocol (STP)

1177


What is n in c?

1108


How can you find the exact size of a data type in c?

1044


What is typedef struct in c?

1094


How is = symbol different from == symbol in c programming?

1102


What is the difference between text and binary modes?

1237


What is the purpose of 'register' keyword in c language?

1069


What are the types of data structures in c?

1210


Is c language still used?

1044


What is #include stdlib h?

1145


What is variable initialization and why is it important?

1333


Write a program to swap two numbers without using third variable?

1347