what i have to do is read in a maximum of 10 animals from a file (one animal per line) but if there are more than 10 animals in the file im supposed to ignore the rest and only read in the first 10. before i start to read in the data am i able to count the number of lines in the file to see if it is more than 10?

Basically all you have to do is set a counter. I assume you're reading the contents of your file in a loop, right? Before the loop do something like:

int counter = 10;
while ( FILE_READ_CONDITIONS && counter>0) {
  // etc
  counter--;
}

Or you could put a counter-- in the while conditions if you like.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.