我遇到了包含头文件的问题,该文件具有sys/type.h
. 当我使用它编译时g++
,gcc filename.cpp
它总是向我显示错误:sys/type.h, no such a file or directory
. 很困惑。有人能帮我吗?
#include<stdio.h>
#include<sys/type.h>
#include<unistd.h>
int main()
{
pid_t child_pid;
printf("the main program ID is %d\n", (int)getpid());
child_pid = fork();
if (child_pid != 0) {
printf("This is the parent process, with id %d\n",
(int)getpid());
printf("the child's process ID is %d\n", (int)child_pid);
} else {
printf("this is the child process, with id %d\n",
(int)getpid());
}
}