This works because the function printWords parameter was correctly declared as an array with char test[]. This means a pointer to the array test. You can pass arrays with this declared as a parameter of your function:

Code:

datatype arrName[]

Also, you assigned an index that was too large for your array. The index.txt is only 9 characters.

Then I tested for the end of file, and while that condition is false read the lines into buffer and print them.