You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:
have access to post topics
communicate privately with other members (PM)
not see advertisements between posts
have the possibility to earn one of our surprises if you are an active member
access many other special features that will be introduced later.
I want to know the line number of the file.
My file's lines are variable length. And I want to learn the number of the line of the file without reading whole file line by line.
can you help me? please..
The only way to know the line number it to count the linefeeds (\n) in the document. Which means you have to read through the whole file to figure it out.
One option is to keep an index of where each line begins in the file. Then you can tell where you are at based on the index. You can store the index in a different file or at the beginning of the file.