Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <sys/types.h>
- #include <unistd.h>
- int main(int argc, char **argv)
- {
- printf("argc = %d\n\n", argc);
- for (int i = 0; i < argc; i++)
- printf("argv[%d]: %s\n", i, argv[i]);
- return 0;
- }
- #include <stdio.h>
- int main(int argc, char **argv, char **env){
- while (*env != 0)
- printf("%s\n", *env++);
- return 0;
- }
- #include <stdlib.h>
- #include <stdio.h>
- #define NAME "PATH"
- int main(){
- char *s;
- s = getenv(NAME);
- (s == 0) ? printf("Variable not defined!\n") : printf("%s = %s\n", NAME, s);
- return 0;
- }
- #include <stdio.h>
- extern char **environ;
- int main(){
- for (int i = 0; environ[i] != 0; i++)
- printf("%s\n", environ[i]);
- return 0;
- }
- #include <sys/types.h>
- #include <unistd.h>
- #include <stdio.h>
- int main(){
- pid_t pid, ppid;
- pid = getpid();
- ppid = getppid();
- printf("PID = %d, PPID = %d\n", pid, ppid);
- return 0;
- }
- #include <stdio.h>
- #include <sys/types.h>
- #include <unistd.h>
- int main(){
- pid_t pid;
- printf("Parent\n");
- pid = fork();
- if (pid == 0)
- printf("Hello, child %d\n", getpid());
- else
- printf("Hello, parent %d\n", getpid());
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement