Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdio.h"
- #include "stdlib.h"
- #include <unistd.h>
- #include "prime.h"
- int main(int argc, char *argv[])
- {
- int number, childNum;
- if (!atoi(argv[1])) {
- printf("Please use a valid integer as an argument!");
- exit(1);
- }
- int pid = fork();
- if (pid == 0) {
- wait(childNum);
- morph(argv[1]);
- }
- else {
- if (childNum == 0) {
- printf("The input number is not a prime number!");
- exit(1);
- }
- else if (childNum == 1) {
- printf("The input number is a prime number!");
- exit(1);
- }
- else if (childNum == 2) {
- printf("Please input a number greater than 2!");
- exit(1);
- }
- }
- }
- void morph(char *number)
- {
- char *primeArgv[] = {
- "isPrime.exe",
- number,
- NULL,
- };
- execvp("isPrime.exe",primeArgv);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement