Hello, can you point out my errors in the code below? #include <iostream> #include…
Jump to turn (8)
- 1Hello, can you point out my errors in the code below? #include #include #include
- 2Where are my errors?
- 3Okay, here is my updated code. Are there still errors? #include #include #includ
- 4Okay, correct my errors
- 5Why did you put wait(NULL) in its own loop?
- 6Why isn't cout << "All child processes terminated. Parent exits." << endl; under
- 7Part 1 Write a C++ program to be named child.cpp and compiled into executable ch
- 8Use execl instead of execvp
- User
Hello, can you point out my errors in the code below? #include #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> #include <stdio.h> using namespace std;
int main(int argc, char* argv[]) //command line argument {
codeint number = argc; cout << "I have " << number << " of children. " << endl; for(int i = 0; i < number < i++){ pid_t pid = fork(); if (pid < 0){ perror("fork failed."); exit(0) } else if (pid == 0){ execvp("./child", argv[i], NULL; exit(0); } } else{ wait(NULL); cout << " I have " << number << " children." << endl; cout << "All child processes terminated. Parent exits." <<endl; exit(0); }}
- Assistant