Computer Science Canada Finding how many lines are in a text file? |
Author: | JayLo [ Wed Dec 15, 2004 11:01 pm ] |
Post subject: | Finding how many lines are in a text file? |
I'm trying to find out how many lines are in a text file, so i know how big my array should be. Actually, is there a more efficient way of getting data, casting it into an Array/Vector with the correct dimensions? |
Author: | Tony [ Wed Dec 15, 2004 11:02 pm ] |
Post subject: | |
Vectors resize themselves, so you can just keep on feeding data into one. |
Author: | JayLo [ Wed Dec 15, 2004 11:08 pm ] | ||
Post subject: | |||
Yeah, Vectors seem to be better. The fileStream still isn't reading in all the lines of text in the file.
where a, b, c, d are Vectors |
Author: | Tony [ Wed Dec 15, 2004 11:30 pm ] |
Post subject: | |
why are there 4 different vectors? |
Author: | wtd [ Wed Dec 15, 2004 11:50 pm ] |
Post subject: | |
Keep different things different! Read the file in in one place, and tokenize the various strings in another. |
Author: | Martin [ Wed Dec 15, 2004 11:55 pm ] |
Post subject: | |
If the file is just a square of text, you could find out how big one line is, compare that to the size of the text file, and calculate the number of lines. |
Author: | wtd [ Thu Dec 16, 2004 9:09 am ] |
Post subject: | |
martin wrote: If the file is just a square of text, you could find out how big one line is, compare that to the size of the text file, and calculate the number of lines.
You know what they say about assuming... |
Author: | Tony [ Thu Dec 16, 2004 6:22 pm ] |
Post subject: | |
well in programming you can safely assume that the user is intellectually challanged and will actually try to break your program ![]() |