Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: seeekg/tellg not working properly?

Reply
Thread Tools

Re: seeekg/tellg not working properly?

 
 
Catalin Pitis
Guest
Posts: n/a
 
      10-20-2004

"Mike Wahler" <(E-Mail Removed)> wrote in message
news:aNDcd.6273$(E-Mail Removed) ink.net...
>
> "Randy Yates" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> Malte Starostik <(E-Mail Removed)> writes:
>>
>> > Randy Yates schrieb:
>> >> void BOOK::GetLine(string &line)
>> >> {
>> >> char linechar[MAX_LINE_SIZE];
>> >> line.erase();
>> >> inpFile.getline(linechar, MAX_LINE_SIZE);
>> >> line.assign(linechar);
>> >> lineNo++;
>> >> };
>> >
>> > FWIW, there's std::getline that takes a std::string as an argument, no
>> > need for hardcoded length limits and a char array:
>> >
>> > using namespace std;
>> >
>> > void BOOK::GetLine(string &line)
>> > {
>> > getline(inpFile, line);
>> > ++lineNo;
>> > }
>> >
>> > Regards,
>> > Malte

>>
>> Thanks Malte, I'll keep that possibility in mind.

>
> But note that 'getline()' depends upon newline characters,
> which can require translation (via a 'text mode' stream)(*),
> and that in 'text mode', 'seek()' and 'tell()' functions
> can never be guaranteed to have a byte-level precision.
>
> (*) Some platforms externally represent '\n' with more than
> a single character. In the C++ memory model, '\n' is
> always a single character. (Ain't I/O fun? )


I had that problem once. I solved it by using the "extended" overload of
getline. I opened the input stream as binary stream and I explicitly
specified the eol character ('\x0A'). For what I had to solve, it was ok.

Catalin


 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
response.redirect is not working but server.transfer is working gaurav tyagi ASP .Net 14 01-20-2006 04:22 AM
wifi not working on new hp, or not working after live update =?Utf-8?B?RHJhZ29ueA==?= Wireless Networking 1 10-01-2005 11:17 PM
ASP.NET client-side validation working, but button click not working Alan Silver ASP .Net 1 08-02-2005 03:50 PM
Cookies working on intranet but NOT working on Internet Martin Heuckeroth ASP .Net 5 04-01-2005 01:37 AM
Regular Expression validators NOT working, Required Field validators ARE working Ratman ASP .Net 0 09-14-2004 09:36 PM



Advertisments