strtok(): Retrieve original string+Item selected after tokenization

40 views Asked by At

I'm using a strtok() to break down a folder path and show it in a TreeView control, something like this:

->/Desktop/Songs
  ->Pop
  ->Country 

Lets say, on the treeview, you select Folder1 (Pop) or Folder2 (Country), is it possible to retrieve the original path + selected item and show it using printf output? So, the path "/Desktop/Songs + userselection"

Path Selected: /Desktop/Songs/Pop  or,
Path Selected: /Desktop/Songs/Country

Code:

HTREEITEM hItem;
HTREEITEM hsubItem;

char line[] = "/Desktop/Songs,Pop,Country" ;   
char* dir= strtok(line,",");    
printf("%s\n", dir);
hItem= treeview.InsertItem(dir); //add to a tree control as the root path or directory

while (dir!= NULL)
{
  dir= strtok(NULL,",");
  printf("%s\n", dir);
  hsubItem = treeview.InsertItem(dir, hItem); //add Pop Country below the 
  first item 
}
0

There are 0 answers