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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!