Question
write program in C which will tokenize the PATH environment variable and pass the result to a procedure. The procedure will then print the results
write program in C which will tokenize the PATH environment variable and pass the result to a procedure. The procedure will then print the results to the console. The tokenized PATH stringwill be stored in an array of string pointers terminated by a 0.
ProgramRequirements
1.The program will call getenv( PATH) to return the $PATH to the program.
2.The program will copy the returned string to a C string (zero terminated array of chars).
3.The program will use the strtok( ) library functionto tokenize the string.
4.The program will load the string pointers returned by strtok() into an array of pointers to strings. The last array element will have a value of0 to terminate the array.
5.The program will pass the array as an argument to a procedure and in a loop print the contents of the array to the console.The declaration of this procedure is printStrings(const char* args[]);
6.The program will be called ShowPath.c.
ShowPath.c
#include
int printStrings(const char* args[]);
int main( )
{
int argc;
const char* argv[100];
printf(add code here);
printStrings(argv);
return 0;
}
int printStrings(const char* args[])
{
printf(add code here);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started