init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
CC = gcc
|
||||
CFLAGS = -Wall -Wextra -Werror
|
||||
|
||||
all: fork.o main.o
|
||||
|
||||
|
||||
is_prime: fork.o main.o
|
||||
$(CC) $^ -o $@
|
||||
|
||||
salute: fork.o main.o
|
||||
$(CC) $^ -o $@
|
||||
|
||||
clean:
|
||||
$(RM) fork.o main.o is_prime salute
|
||||
|
||||
.PHONY: all clean run
|
||||
@@ -0,0 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "fork.h"
|
||||
|
||||
int is_prime(size_t n)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
int salute(int num_guests, char *guests[])
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef FORK_H
|
||||
#define FORK_H
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
int is_prime(size_t n);
|
||||
int salute(int num_guests, char *guests[]);
|
||||
|
||||
#endif /* FORK_H */
|
||||
@@ -0,0 +1,28 @@
|
||||
// This file will not be tested, you can modify it.
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "fork.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (!strcmp(argv[0], "./is_prime"))
|
||||
{
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
is_prime(atoi(argv[i]));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(argv[0], "./salute"))
|
||||
{
|
||||
return salute(argc, argv);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("No such thing as %s\n", argv[0]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user