を使用fgetsして行全体をメモリに読み込み、次にstrtok行を個々の要素にトークン化することをお勧めします。
次のコードは、これを行う 1 つの方法を示しています。まず、ヘッダーと構造定義:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct sMyPath {
    char *element;
    struct sMyPath *next;
} tMyPath;
次に、最初に空のリストを作成し、次にユーザーからの入力を取得する main 関数 (堅牢な入力関数が必要な場合は、こちらを参照してください。以下に続くのは、デモ目的でのみ、その簡略化されたバージョンです):
int main(void) {
    char *token;
    tMyPath *curr, *first = NULL, *last = NULL;
    char inputStr[1024];
    // Get a string from the user (removing newline at end).
    printf ("Enter your string: ");
    fgets (inputStr, sizeof (inputStr), stdin);
    if (strlen (inputStr) > 0)
        if (inputStr[strlen (inputStr) - 1] == '\n')
            inputStr[strlen (inputStr) - 1] = '\0';
次に、すべてのトークンを抽出してリンク リストに追加するコード。
    // Collect all tokens into list.
    token = strtok (inputStr, "/");
    while (token != NULL) {
        if (last == NULL) {
            first = last = malloc (sizeof (*first));
            first->element = strdup (token);
            first->next = NULL;
        } else {
            last->next = malloc (sizeof (*last));
            last = last->next;
            last->element = strdup (token);
            last->next = NULL;
        }
        token = strtok (NULL, "/");
    }
(これは標準の C ではありませんが、適切な実装をいつでもどこかstrdupで見つけることができることに注意してください)。次に、リンクされたリストを出力して、適切にロードされたことを示し、クリーンアップして終了します。
    // Output list.
    for (curr = first; curr != NULL; curr = curr->next)
        printf ("[%s]\n", curr->element);
    // Delete list and exit.
    while (first != NULL) {
        curr = first;
        first = first->next;
        free (curr->element);
        free (curr);
    }
    return 0;
}
サンプルの実行は次のとおりです。
Enter your string: path/to/your/file.txt
[path]
[to]
[your]
[file.txt]
また、C++ ではstruct構造体からキーワードを除外できますが、C ではそうではありません。あなたの定義は次のとおりです。
struct MyPath {
    char *element;         // Pointer to the string of one part.
    struct MyPath *next;   // Pointer to the next part - NULL if none.
};