int main (int argc, char* argv[]){
int toSleep;
int produce;
int consume;
int i = 0;
//get the values for sleep, produce, consume
toSleep = atoi(argv[1]);
produce = atoi(argv[2]);
consume = atoi(argv[3]);
//check if the user input a vaild inpusts
//if(argc !=4){
//printf("You are missing an input\n");
// exit(0);
//}`enter code here`
if(toSleep == '\0' || produce == '\0' || consume == '\0' ){
printf("You are missing an input\n");
exit(0);
}else if (toSleep <=0 || produce<= 0 || consume <=0 ){
printf("Please provide a vaild inputs \n");
exit(0);
}else {
//continue to the program
}
I am trying to make sure that the user will input exactly 3 inputs; if one is missing or null, I should print an error message and terminate the program. I always get this error when I tried to compile it
./a4 makefile:5: recipe for target 'semaphore' failed make: *** [semaphore] Segmentation fault (core dumped)
Can someone tell me what I did wrong here?