There is another function named gets which is similar to fgets , but notoriously dangerous to use. I suggest that you never use it. The rewind function is a special case of the fseek that can be used to rewind to the beginning of a file. This can be handy on assignment 8. In addition, if there is a path, this function specifies one possible path.
Recursion is very useful, and a very elegant recursive solution is easy to write.
Just attack this problem like any other- figure out what the base cases are, and what values to return for each, and then figure out what the recursive cases are. You may want to rethink your algorithm. Do not be overly concerned with efficiency, just try to come up with a solution. Unless you do something silly, even a seemingly inefficient solution will be of the same order as a good one. Descriptions for how to do this are given in labyrinth.txt .