🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: att.lang.c++
Article #92

Re: more strtok()

#92
From: 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
Technical Details
Message-ID: <kErT4.953$XW.28055@news2-win.server.ntlworld.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8fl019$8o5$1@bob.news.rcn.net>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d4ba,8c804c30a79cfe3c
X-Google-Attributes: gid10d4ba,public
X-Google-Thread: 109fba,8c804c30a79cfe3c
X-Google-Attributes: gid109fba,public
From: "John Harrison" <jahhaj@dtn.ntl.com>
Subject: Re: more strtok()
Date: 2000/05/14
Message-ID: <kErT4.953$XW.28055@news2-win.server.ntlworld.com>
X-Deja-AN: 623163455
References: <8fl019$8o5$1@bob.news.rcn.net>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
X-Complaints-To: abuse@net.ntl.com
X-Trace: news2-win.server.ntlworld.com 958285456 194.168.244.112 (Sun, 14 May 2000 07:24:16 BST)
Organization: ntl News Service
X-MSMail-Priority: Normal
Reply-To: "John Harrison" <jahhaj@bigfoot.com>
NNTP-Posting-Date: Sun, 14 May 2000 07:24:16 BST
Newsgroups: att.lang.c++,comp.lang.c++