From 0e61abb6ccc1e5010242101ddf096a2e0582ec2a Mon Sep 17 00:00:00 2001 From: bjt-user Date: Wed, 1 May 2024 15:42:23 +0200 Subject: [PATCH] print_children func works --- main.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/main.go b/main.go index f5ac434..55995f5 100644 --- a/main.go +++ b/main.go @@ -71,6 +71,16 @@ func get_parents(headings []heading) { } } +func print_children(heading *heading, headings []heading) { + fmt.Printf("pointer of parent: %p\n", heading) + + for index, _ := range headings { + if headings[index].parent == heading { + fmt.Printf("Header of parent %p: %s\n", heading, headings[index].text) + } + } +} + func main() { file_content_raw, err := os.ReadFile(os.Args[1]) @@ -93,6 +103,12 @@ func main() { get_parents(headings) + // print all children that do not have a parent + //print_children(nil, headings) + + // print all children of the second header + print_children(&headings[1], headings) + fmt.Printf("%v\n", headings) header_level_count := count_levels(headings)