Re: strtok() and EOL



Fernando Barsoba wrote:
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\r\n"

Thanks to all for your comments. Indeed, the string I'm getting is "message:this is a test\r\n". And 'pmsg' comes also from a file. Oddly enough, I thought I opened the file in text mode. Here's the sequence of calls:

fp = open_file(argv[1], "r");

Yes, that is opening in text mode.

<snip>

As the comments pointed out, this seems to be a Windows issue. That's why in Linux works fine. I'm not opening the file in binary mode though..

See my previous post, it's a Cygwin issue. Specifically, Cygwin is emulation Unix to a degree (that is its purpose) so by default it used the Unix text file conventions. Ask on a Cygwin mailing list for the details.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
.




Relevant Pages

  • Re: How to print a file in binary mode
    ... well, if I just open the file in binary mode, and write a string,e.g ... > so I first convert the string to binary,and then saving the binary ... you get an 8-bit string that contains the binary data. ... print the picture by binary! ...
    (comp.lang.python)
  • Re: Reading from a Serial Port Part II
    ... No other routine is required. ... the string value of the binary? ... just fine and can receive data fine in text mode but not in binary mode. ... Private Sub Form1_Load(ByVal sender As System.Object, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Write to binary file
    ... I just thought that by writing text in binary mode it would make it unreadable. ... The string is here is ascii text. ... In C data types are handled quite more complex (well, under water this is also true for PHP, but you needn't concern yourself with it while writing in PHP), possibly generating a different representation when outputting the raw data. ...
    (comp.lang.php)
  • Re: reading from a text file
    ... So it's not my code anyway, and it's pre-ansi:P ... This code did not return a string containing a null. ... If it was opened in binary mode, ... The standard forbids text files to contain nulls? ...
    (comp.lang.c)