This is what so far i did
Code:
#include <stdio.h>#include <string.h>
#include <ctype.h>
#include <bsd/string.h>
int
main(void)
{
char line[100];
fgets(line, sizeof line, stdin); // read in one line
// from the user
char words[3][100];
// we are able to store 3 words in
// this array, each one 100 characters
// in length
int last_was_space = 1;
int begin = 0;
int word = 0;
for (int i = 0; i < strlen(line); i++) {
if (last_was_space) {
begin = i;
}
if (isspace(line[i])) {
strlcpy(words[word], line + begin, i - begin + 1);
word++;
last_was_space = 1;
} else {
last_was_space = 0;
}
}
char *words_p[3];
for (int i = 0; i < sizeof words / sizeof *words; i++) {
words_p[i] = words[i];
}
for (int i = 0; i < word; i++) {
printf("%s\n", words_p[i]);
}
return 0; }
need help to do this
- Using the fork(), execvp() and waitpid() system calls, launches the requested program and waits until the program has finished