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...

write a C program to print the program itself ?!

Answer Posted / jaroosh

The most simple possible program printing itself on windows :
main()
{
char path[255];
sprintf(path,"cmd.exe /c type \"%s\"",__FILE__);
system(path);
}

on Unix you just use "cat" instead of "type" and necessary
fun to call bash command from c program.

Is This Answer Correct ?    17 Yes 23 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

can we have joblib in a proc ?

2310


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

2178


Why do we use main function?

1183


What is difference between structure and union in c?

991


What are the 4 types of functions?

1060


What do you mean by invalid pointer arithmetic?

1079


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

1247


How can I delete a file?

1067


write a program to concatenation the string using switch case?

2108


Is it better to bitshift a value than to multiply by 2?

1094


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

1036


How do I determine whether a character is numeric, alphabetic, and so on?

1139


What is multidimensional arrays

1130


What is the use of volatile?

1084


What is d'n in c?

1124