Answer:
#include<stdio.h>
#include <stdlib.h>
#include <unistd.h>
void path() {
char path[100];
if (getcwd(path, sizeof(path)) != NULL) {
printf("path: %s\\", path);
} else {
perror("getcwd() error");
}
}
void addPath(char *a) {
char path[100];
if (getcwd(path, sizeof(path)) != NULL) {
printf("path: %s %s\\", path,a);
} else {
perror("getcwd() error");
}
}
void removePath(char *a) {
char path[100];
if (getcwd(path, sizeof(path)) != NULL) {
int len = (strlen(path)-strlen(a));
printf("(%.*s)\\", len, path);
} else {
perror("getcwd() error");
}
}
int main()
{
char userInput[100] =" ";
char userInput2[100 ]= " ";
printf("Current Path");
path();
printf("Enter Path to be added\\");
scanf("%s", &userInput);
addPath(userInput);
printf("Enter Path to be removed\\");
scanf("%s", &userInput2);
removePath(userInput2);
return 0;
}