Top Qs
Timeline
Chat
Perspective
C process control
Functions of the C standard software library From Wikipedia, the free encyclopedia
Remove ads
C process control refers to a group of functions in the standard library of the C programming language implementing basic process control operations.[1][2] The process control operations include actions such as termination of the program with various levels of cleanup, running an external command interpreter or accessing the list of the environment operations.
Overview of functions
The process control functions are defined in the stdlib.h header (cstdlib header in C++).
Remove ads
Example
The following is an example of communicating with the system environment in C.
#include <stdio.h>
#include <stdlib.h>
int main() {
char* path = getenv("PATH");
if (!path) {
fprintf(stderr, "PATH environment variable not found.\n");
} else {
printf("PATH variable: %s\n", path);
}
printf("Listing current directory contents using system(\"ls\"):\n");
int ret = system("ls");
if (ret == -1) {
fprintf(stderr, "system() call failed!");
}
return 0;
}
Remove ads
References
External links
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads