Harvard - CS50 Week3 Review
Why struct is important? The struct data type offers a way to represent the concept of abstraction, helping us create software that is both understandable and less prone to errors. For example, we can use two arrays to represent people’s name and phone number. func main() { people := [3]string{"Andy", "Ben", "Cindy"} phoneNumber := [3]string{"0911-111-111", "0922-222-222", "0933-333-333"} fmt.Printf("%s's number is %s\n", people[0], phoneNumber[0]) } This code is highly prone to errors, such as the possibility of a typo mistake leading to an incorrect assignment of phone numbers....