2013-05-02 117 views
-3

如何創建文件/目錄樹的結構。 c程序通過每個txt文件的路徑的shell腳本獲得一個txt文件輸入。例如爲文件/目錄樹創建結構

a\a1.txt 
a\m\m1.txt 

你將如何爲此創建一個結構?

+2

使用'struct'關鍵字,排在首位。 – 2013-05-02 20:37:09

+1

結構是一種組織數據的方式。您的程序將如何處理從輸入文件讀取的數據? – chepner 2013-05-02 20:51:39

+1

用戶運行C程序並輸入文本文件的名稱時,應該搜索文件 – 2013-05-02 20:52:30

回答

1

也許

字符串的簡單的一根維弦​​

struct MyPath { 
    char *element; // Pointer to the string of one part. 
    MyPath *next; // Pointer to the next part - NULL if none. 
} 

的滿二叉樹表示

struct Node { 
    char *element; // Pointer to the string - node. 
    Node *left; // Pointer to the left subtree. 
    Node *right; // Pointer to the right subtree. 
}