-
April 16th, 2012, 10:11 PM
#1
Get Address of Line (Reading Files)
If I'm reading a text file line by line, how do I get the byte address of the start of each line?
-
April 16th, 2012, 11:25 PM
#2
Re: Get Address of Line (Reading Files)
That depends, how are you reading the lines in? I'm assuming you're using C++, so if you have a string or CString, you can just use &variableName.
-
April 16th, 2012, 11:39 PM
#3
Re: Get Address of Line (Reading Files)
I'm using string class.
ifstream file;
name = 'text.txt';
file.open(name.data());
while(getline(file, lnstr))
{
cout << file.seekg();
}
This is what I was doing, but it keeps spitting out the same number. I want to spit it out line by line what the address is. On another note I'm trying to show it as byte values, specifically in 8bytes.
Last edited by Howdy_McGee; April 16th, 2012 at 11:50 PM.
-
April 17th, 2012, 05:23 AM
#4
Re: Get Address of Line (Reading Files)
1) use tellg() not seekg()
2) care should be taken when using seekg/tellg using VC++ if the file is opened
in text mode.
3) it is still not clear to me why you need that information
-
April 17th, 2012, 06:11 AM
#5
Re: Get Address of Line (Reading Files)
-
April 17th, 2012, 07:11 AM
#6
Re: Get Address of Line (Reading Files)
What do you mean by "address", the offset from the start of the file? Just count the length of each line, making sure to account for the new line characters.
What do you mean by 8byte?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|