Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: how to do this? |
| Date | 2015-11-15 13:24 +1300 |
| Message-ID | <daq1m2Fi0ttU12@mid.individual.net> (permalink) |
| References | (1 earlier) <dapqp9Fi0ttU9@mid.individual.net> <n28emj$nl3$1@dont-email.me> <n28fpg$rmm$1@dont-email.me> <daq0r5Fi0ttU10@mid.individual.net> <5647D007.2010207@verizon.net> |
James Kuyper wrote: > On 11/14/2015 07:10 PM, Ian Collins wrote: >> bilsch01 wrote: > .... >>> Oh. The vec1 , vec2 . . . aren't null terminated. I don't see any >>> way to fix that. >> >> Your code as written implied that they were null terminated by using >> strxxx functions to compare and copy them. > > True. However, he opened the file in text mode, which means that even if > null characters were written to that file, there's no guarantee that > they'll still be there when read back from the file. That's because of > 7.21.2p2: > > "Data read in from a text stream will necessarily compare equal to the > data that were earlier written out to that stream only if: the data > consist only of printing characters and the control characters > horizontal tab and new-line; no new-line character is immediately > preceded by space characters; and the last character is a new-line > character." > > Therefore, if a file contains null characters, it should be read in > binary mode, not text mode. Good spot! -- Ian Collins
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how to do this? bilsch01 <king621@comcast.net> - 2015-11-14 12:09 -0800
Re: how to do this? Rosario19 <Ros@invalid.invalid> - 2015-11-14 21:49 +0100
Re: how to do this? Ian Collins <ian-news@hotmail.com> - 2015-11-15 10:02 +1300
Re: how to do this? Ian Collins <ian-news@hotmail.com> - 2015-11-15 10:17 +1300
Re: how to do this? bilsch01 <king621@comcast.net> - 2015-11-14 15:16 -0800
Re: how to do this? James Kuyper <jameskuyper@verizon.net> - 2015-11-14 18:24 -0500
Re: how to do this? bilsch01 <king621@comcast.net> - 2015-11-14 15:30 -0800
Re: how to do this? Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2015-11-14 19:01 -0500
Re: how to do this? James Kuyper <jameskuyper@verizon.net> - 2015-11-14 19:07 -0500
Re: how to do this? Ian Collins <ian-news@hotmail.com> - 2015-11-15 11:26 +1300
Re: how to do this? bilsch01 <king621@comcast.net> - 2015-11-14 15:07 -0800
Re: how to do this? James Kuyper <jameskuyper@verizon.net> - 2015-11-14 18:17 -0500
Re: how to do this? bilsch01 <king621@comcast.net> - 2015-11-14 15:25 -0800
Re: how to do this? Ian Collins <ian-news@hotmail.com> - 2015-11-15 13:10 +1300
Re: how to do this? James Kuyper <jameskuyper@verizon.net> - 2015-11-14 19:21 -0500
Re: how to do this? Ian Collins <ian-news@hotmail.com> - 2015-11-15 13:24 +1300
Re: how to do this? James Kuyper <jameskuyper@verizon.net> - 2015-11-14 19:12 -0500
Re: how to do this? Ian Collins <ian-news@hotmail.com> - 2015-11-15 13:18 +1300
Re: how to do this? James Kuyper <jameskuyper@verizon.net> - 2015-11-14 19:23 -0500
Re: how to do this? bilsch01 <king621@comcast.net> - 2015-11-14 15:18 -0800
csiph-web