Raised This Month: $51 Target: $400
 12% 

Solved How to get line/character number from file?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 03-30-2019 , 23:24   How to get line/character number from file?
Reply With Quote #1

So if I have a file open for reading like this:
Code:
File file = OpenFile("file.txt", "r");
How would I go about getting the line/character number from this file after doing something like
Code:
file.ReadLine(buffer, sizeof(buffer));
I've tried using the file.Position property but that seems to return random values and I haven't tried using FilePosition() since I assume it uses the same thing that file.Position does.

Last edited by CliptonHeist; 03-31-2019 at 18:27.
CliptonHeist is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 03-31-2019 , 08:11   Re: How to get line/character number from file?
Reply With Quote #2

PHP Code:

int pos 
0;

while (
file.ReadLine(buffersizeof(buffer))
{
     
// we are now on pos 0 (or index 0);
     
pos++;
}

// now number of lines == pos; 
__________________
Ilusion9 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode