Question: I have a file stream in C and I want to know how many lines are in it without iterating through the file. Each line is the same length. How might I go about this?

Answer: 
How about something like this:

* Do a `fgets` and find out how long one line is
* Find the size of the file using `fseek` and `ftell`

```
fseek(fp, 0, SEEK_END);
size = ftell(fp);

```
* Divide by the size of the line

You can also use `fseeko` and `ftello` which work with `off_t`.
Read one line, `stat()` the file to [get the total size](https://stackoverflow.com/questions/238603/how-can-i-get-a-files-size-in-c), divide the total size by the length of the first line.

Instead of using `stat()` you could also `fseek()` to the end of the file and then use `ftell()` to get the size.