🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

2 total messages Started by Henry Zektser Sat, 13 May 2000 00:00
more strtok()
#90
Author: Henry Zektser
Date: Sat, 13 May 2000 00:00
10 lines
1217 bytes
Ok, I know I'm harassing everyone with this one function, but nothing else
gives me any trouble. At the moment I'm using ifstream::getline() to read a
file line by line into a char*, which I'm using a strtok() call on, with the
separators being ' \n' (space and newline) and maxchars being far bigger
than the width of the file. It works fine, unless I leave a blank line (hit
enter twice in notepad, and save). Then it gives me an access violation
error. What exactly does getline return in this case, and/or why isnt strtok
handling it correctly?

H
Re: more strtok()
#92
Author: John Harrison
Date: Sun, 14 May 2000 00:00
27 lines
1869 bytes
Henry Zektser <kdentdev@hotmail.com> wrote in message
news:8fl019$8o5$1@bob.news.rcn.net...
> Ok, I know I'm harassing everyone with this one function, but nothing else
> gives me any trouble. At the moment I'm using ifstream::getline() to read
a
> file line by line into a char*, which I'm using a strtok() call on, with
the
> separators being ' \n' (space and newline) and maxchars being far bigger
> than the width of the file. It works fine, unless I leave a blank line
(hit
> enter twice in notepad, and save). Then it gives me an access violation
> error. What exactly does getline return in this case, and/or why isnt
strtok
> handling it correctly?
>
> H
>
>

In this case getline returns a zero length string. Given a zero length
string strtok will return 0 (otherwise known as NULL). I would guess that
your code assumes that a line contains at least one valid token and
therefore you end up deferencing a null pointer. But without seeing your
code its only a guess, don't be shy, POST YOUR CODE.

john
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads