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 manipulate individual bits?

603


What is Dynamic memory allocation in C? Name the dynamic allocation functions.

551


Why can’t constant values be used to define an array’s initial size?

825


How many levels of pointers have?

585


How can a process change an environment variable in its caller?

647






Write a program that takes a 5 digit number and calculates 2 power that number and prints it(should not use big integers and exponential functions)

5786


Write a program to find the biggest number of three numbers in c?

584


What are different types of variables in c?

564


What is the difference between exit() and _exit() function in c?

576


What is a structural principle?

634


which of the following is not a character constant a) 'thank you' b) 'enter values of p, n ,r' c) '23.56E-o3' d) all of the above

1409


what is the significance of static storage class specifier?

1653


What are the string functions? List some string functions available in c.

596


Is there a way to have non-constant case labels (i.e. Ranges or arbitrary expressions)?

574


What are structure members?

588