Fill This Form To Receive Instant Help
Homework answers / question archive / Make a program, calling it exec
Make a program, calling it exec. c make a correction
Remember to include the headers as needed.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/errno.h>
#include <unistd.h>
int main (int argc, char *argv[]){
execlp("/usr/bin/grap", "grap", "he", "test.txt", NULL);
printf("Could not exec program. Errno is %dn", errno);
perror(" lab ");
exit(1);
this is not working
}
And the excel call does not work. But you did just verify that the errno, perror, and exit calls work as expected. This is a good thing; when you test your programs, you should test their response if unexpected things happen.
test.txt
(Food is any substance consumed by an organism for nutritional support. Food is usually of plant, animal, or fungal origin, and contains essential nutrients, such as carbohydrates, fats, proteins, vitamins, or minerals. The substance is ingested by an organism and assimilated by the organism's cells to provide energy, maintain life, or stimulate growth. Different species of animals have different feeding behaviours that satisfy the needs of their unique metabolisms, often evolved to fill a specific ecological niche within specific geographical contexts.
Omnivorous humans are highly adaptable and have adapted to obtain food in many different ecosystems. Historically, humans secured food through two main methods: hunting and gathering and agriculture.)
now make a correction
you probably see what is wrong in the "execlp" call; there is a "grep" utility, but no "grap" utility. Change the execlp call to the following:
execlp("/usr/bin/grap", "grap", "he", "test.txt", NULL);
Then compile and run this version.
What is the "execlp" command doing in this code? What is the equivalent command from the terminal prompt?