What is the variable buf for? My teacher told me to put it but I don't know why!
The variable "buf" with the pair of square brackets "" means an array! A set of contiguous memory locations being used to store the similar kinda data value. Here in this case, you use a container to store a set of characters. so you need an array of characters.