Re: strtok() and EOL
- From: Flash Gordon <spam@xxxxxxxxxxxxxxxxxx>
- Date: Tue, 29 Nov 2005 20:02:57 +0000
Jack Klein wrote:
On Tue, 29 Nov 2005 15:16:17 GMT, Fernando Barsoba <fbarsoba@xxxxxxxxxxx> wrote in comp.lang.c:
<snip>
>>message:this is a test
(when 'this is a test\n' is only 14 characters long, w/o the '\n')
In other installations (Linux) works just fine, but in my Eclipse/CDT/cygwin sometimes is not.
Am I using strtok incorrectly? is the 's2' pointer messing things up?
Thanks,
F~
Where did the text string passed in 'pmsg' come from? Was it read from a file? If it was read from a file, was the file opened in text or binary mode? If you are reading a text file opened in binary mode under Windows, you are getting the string as it appears in the file, which would be:
"message:this is a test\r\n"
Note that since Cygwin is emulating some of Unix it may think of \n as being the line terminator rather than \r\n even when you open a stream in text mode, so you could still get a spurious \r. For the intricacies of Cygwin line termination you will have to ask on a Cygwin mailing list, but if this is your problem one option is to check if the last character of the line you read is \r and if so strip it.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
.
- References:
- strtok() and EOL
- From: Fernando Barsoba
- Re: strtok() and EOL
- From: Jack Klein
- strtok() and EOL
- Prev by Date: Re: Read dynamic string
- Next by Date: Re: sizeof a union
- Previous by thread: Re: strtok() and EOL
- Next by thread: Re: strtok() and EOL
- Index(es):
Relevant Pages
|