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

Explain the difference between structs and unions in c?

980


What is the best way to comment out a section of code that contains comments?

1299


Why is event driven programming or procedural programming, better within specific scenario?

2386


What does c mean before a date?

1144


What is the need of structure in c?

1080


How many levels of pointers have?

1012


What is f'n in math?

1025


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

1002


An organised method of depicting the use of an area of computer memory used to signify the uses for different parts of the memory a) swap b) extended memory c) memory map d) all of the above

1131


Are bit fields portable?

1126


What is pointer and structure in c?

1107


Do you know the use of 'auto' keyword?

1147


Why is extern used in c?

1070


What do you understand by normalization of pointers?

1024


.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }

1252