#include <stdio.h>
#include <string.h>

char* stack[100];
int top = -1;

void push(char* dir) {
    stack[++top] = dir;
}

void pop() {
    top--;
}

int main() {
    char path[] = "/home/user/docs/../music/";
    char *token;

    token = strtok(path, "/");

    while (token != NULL) {
        if (strcmp(token, "..") == 0) {
            pop();
        } else {
            push(token);
        }
        token = strtok(NULL, "/");
    }

    printf("/");
    for (int i = 0; i <= top; i++) {
        printf("%s", stack[i]);
        printf("/");
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: