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 / neenu jacob

#include <stdio.h>

main()
{
int pid,ppid;
int q=getpid();
int gid,egid,uid,euid;
int f=fork();
if (f==0)
{
printf("hai\n%d\n%d\n%d",getuid(),geteuid());

}
else
{
pid=getpid();
ppid=getppid();
printf("%d\n%d\n%d\n%d",pid,ppid,q,f);
}
system("cat /home/mec/lab1.c");
}

Is This Answer Correct ?    0 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I open files mentioned on the command line, and parse option flags?

1068


What is const keyword in c?

1158


What are the differences between Structures and Arrays?

1202


What is memcpy() function?

1113


What is array in C

1150


What are the rules for the identifier?

1158


Explain what does a function declared as pascal do differently?

1274


Why do we need volatile in c?

1164


What is line in c preprocessor?

1048


What is union and structure?

1114


What is self-referential structure in c programming?

1207


What are the types of c language?

1024


If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?

1252


to find the closest pair

2321


How can I call system when parameters (filenames, etc.) Of the executed command arent known until run time?

1099