im new to C++ and it was hard for me to find a good IDE. Now i have Code Blocks, but i cant use the Systemcalls like fork, wait etc.
I use Windows 7.
#include <iostream>
#include <stdlib.h>;
#include <sys/types.h>
#include <unistd.h>
using namespace std;
int main()
{
cout << "I am " << (int) getpid() << endl;
pid_t pid = fork();
cout << "fork returned" << (int) pid << endl;
return 0;
if(pid<0) {
cout << "Failed !" << endl;
exit(3);
}
if(pid == 0) {
cout << "i am the child" << (int) getpid() << endl;
cout << "Child exiting" << endl;
exit(0);
}
if(pid >= 0) {
cout << "i am the parent" << (int) getpid() << endl;
wait(NULL);
cout << "Parent ending" << endl;
}
return 0;
}
I cant include sys/wait.h Errors :
error : fork was not declared in this scope error : wait was not declared in this scope
Thanks in advice !