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.
In Java, you declare the array in this way!
Another thing I don't understand is why does it stop at the first "_"? Shouldn't it display "his_i"? (i.e. Up until index 5 since int end=5)
Well, end is 5 and start is 1. so, (end-start) will give you 4 (5-1=4 ). As the arrays always start with 0 instead of 1, you will get upto 4.