Error
In function ‘main’:
assignment.c:46:14: warning: implicit declaration of function ‘fork’ [-Wimplicit-function-declaration]
46 | int pid= fork();
| ^~~~
assignment.c:49:9: warning: implicit declaration of function ‘execvp’ [-Wimplicit-function-declaration]
49 | execvp(command[0],command);
| ^~~~~~
assignment.c:54:9: warning: implicit declaration of function ‘wait’ [-Wimplicit-function-declaration]
54 | wait(NULL);
| ^~~~
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char line[200];
char* command[100];
char progpath[20];
int argc;
while(1){
printf("Enter command and press ctrl + D or type Exit to terminate program \n ");
if(!fgets(line, 200, stdin)){
break;
}
size_t length = strlen(line);
if(line[length - 1] == '\n')
line[length - 1] = '\0';
if(strcmp(line, "exit")==0){
break;
}
char *token;
token = strtok(line," ");
int i=0;
while(token!=NULL){
command[i]=token;
token = strtok(NULL," ");
i++;
}
command[i]=NULL;
argc=i;
for(i=0; i<argc; i++){
printf("%s\n", command[i]);
}
for(i=0; i<strlen(progpath); i++){
if(progpath[i]=='\n'){
progpath[i]='\0';
}
}
int pid= fork();
if(pid==0){
execvp(command[0],command);
fprintf(stderr, "Child process could not do execvp\n");
}
else{
wait(NULL);
printf("Child exited\n");
}
}
}
pls help me to solve this problem as soon as possible