recursively printing children works
This commit is contained in:
parent
0e61abb6cc
commit
5dc6ce8daa
15
main.go
15
main.go
@ -81,6 +81,17 @@ func print_children(heading *heading, headings []heading) {
|
||||
}
|
||||
}
|
||||
|
||||
func print_children_recursive(heading *heading, headings []heading) {
|
||||
//fmt.Printf("pointer of parent: %p\n", heading)
|
||||
|
||||
for index, _ := range headings {
|
||||
if headings[index].parent == heading {
|
||||
fmt.Printf("Child of parent %p: %s\n", heading, headings[index].text)
|
||||
print_children_recursive(&headings[index], headings)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
file_content_raw, err := os.ReadFile(os.Args[1])
|
||||
|
||||
@ -107,7 +118,9 @@ func main() {
|
||||
//print_children(nil, headings)
|
||||
|
||||
// print all children of the second header
|
||||
print_children(&headings[1], headings)
|
||||
//print_children(&headings[1], headings)
|
||||
|
||||
print_children_recursive(nil, headings)
|
||||
|
||||
fmt.Printf("%v\n", headings)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user