Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #12972

Re: Character Array vs String

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From James Kuyper <jameskuyper@verizon.net>
Newsgroups comp.lang.c
Subject Re: Character Array vs String
Date Wed, 09 Nov 2011 11:30:35 -0500
Organization A noiseless patient Spider
Lines 26
Message-ID <4EBAAAAB.5080308@verizon.net> (permalink)
References <bb3e536d-ddae-4dab-ab1c-bbb2967da95d@j36g2000prh.googlegroups.com> <slrnjbkqmr.pt.qcarbonn@localhost.localdomain> <3278969.27.1320842921986.JavaMail.geo-discussion-forums@prep8> <670026a6-8f9d-4112-bf32-444a3a5fd3f7@m7g2000vbc.googlegroups.com> <7558688f-8b99-49d1-a318-215ea7e22d1e@e2g2000vbb.googlegroups.com> <4EBAA4F7.80503@verizon.net> <slrnjblaaj.2t4n.willem@toad.stack.nl>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1
Content-Transfer-Encoding 7bit
Injection-Info mx04.eternal-september.org; posting-host="2P71cupDoazVVolqpw1jrw"; logging-data="13025"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19uTuJ9B0+qxWSNxug4kylAlglM8FMJg04="
User-Agent Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.23) Gecko/20110920 Thunderbird/3.1.15
In-Reply-To <slrnjblaaj.2t4n.willem@toad.stack.nl>
Cancel-Lock sha1:bOd34axrCA384X6fUm28ZD7P08c=
Xref x330-a1.tempe.blueboxinc.net comp.lang.c:12972

Show key headers only | View raw


On 11/09/2011 11:24 AM, Willem wrote:
> James Kuyper wrote:
> ) On 11/09/2011 10:48 AM, Malcolm McLean wrote:
> ) ...
> )> For instance IFF files have 4-letter ASCII tags which indicate what
> )> sort of "chunk" you are reading. So the obvious thing to write is
> )> 
> )> fread(chunk, 1, 4, fp);
> )> if(!strncmp(chunk, "DATA", 4))
> )>   /* we've got a data chunk */
> )> 
> )> That will break on a non-ascii system. The solution is to hardcode the
> )> values. But then you can no longer read the word "DATA" and it becomes
> )> a lot harder to see that the chunk identifier is correct.
> )
> ) You can make it a macro, whose name is more informative than the
> ) hardcoded values. However, the better solution (though not always
> ) feasible) is to convert those files from ASCII to the native encoding on
> ) that platform,
> 
> They are not ASCII files.  They are binary files with chunks that are
> identified by a 4-byte header which has meaning when read as ASCII.

That makes it harder; the conversion utility would have to know about
the file format. It's still not impossible, but obviously far less
convenient.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Character Array vs String Sheky <shekhar07.nitdgp@gmail.com> - 2011-11-09 03:09 -0800
  Re: Character Array vs String Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-09 03:28 -0800
  Re: Character Array vs String James Kuyper <jameskuyper@verizon.net> - 2011-11-09 06:52 -0500
  Re: Character Array vs String Quentin Carbonneaux <qcarbonn@invalid.com> - 2011-11-09 12:01 +0000
    Re: Character Array vs String 88888 Dihedral <dihedral88888@googlemail.com> - 2011-11-09 04:48 -0800
      Re: Character Array vs String Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-09 05:53 -0800
        Re: Character Array vs String "osmium" <r124c4u102@comcast.net> - 2011-11-09 09:44 -0600
          Re: Character Array vs String Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-10 00:57 -0800
            Re: Character Array vs String "osmium" <r124c4u102@comcast.net> - 2011-11-10 08:56 -0600
              Re: Character Array vs String Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-10 08:16 -0800
                Re: Character Array vs String "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2011-11-10 18:34 +0100
                Re: Character Array vs String Kenneth Brody <kenbrody@spamcop.net> - 2011-11-10 14:08 -0500
                Re: Character Array vs String Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-10 20:52 +0000
                Re: Character Array vs String Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-11 01:29 -0800
              Re: Character Array vs String Lowell Gilbert <lgusenet@be-well.ilk.org> - 2011-11-10 12:29 -0500
              Re: Character Array vs String lawrence.jones@siemens.com - 2011-11-10 12:32 -0500
                Re: Character Array vs String Keith Thompson <kst-u@mib.org> - 2011-11-10 12:41 -0800
                Re: Character Array vs String jt@toerring.de (Jens Thoms Toerring) - 2011-11-11 13:12 +0000
              Re: Character Array vs String David Thompson <dave.thompson2@verizon.net> - 2011-11-21 02:39 -0500
                Re: Character Array vs String Kenneth Brody <kenbrody@spamcop.net> - 2011-11-23 11:39 -0500
                Re: Character Array vs String "BartC" <bc@freeuk.com> - 2011-11-23 17:15 +0000
                Re: Character Array vs String Kaz Kylheku <kaz@kylheku.com> - 2011-11-23 18:48 +0000
                Re: Character Array vs String Ben Pfaff <blp@cs.stanford.edu> - 2011-11-23 10:58 -0800
                Re: Character Array vs String Patrick Scheible <kkt@zipcon.net> - 2011-11-27 20:21 -0800
                Re: Character Array vs String David Thompson <dave.thompson2@verizon.net> - 2012-01-19 02:43 -0500
        Re: Character Array vs String Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-09 07:48 -0800
          Re: Character Array vs String James Kuyper <jameskuyper@verizon.net> - 2011-11-09 11:06 -0500
            Re: Character Array vs String Willem <willem@toad.stack.nl> - 2011-11-09 16:24 +0000
              Re: Character Array vs String James Kuyper <jameskuyper@verizon.net> - 2011-11-09 11:30 -0500
                Re: Character Array vs String "BartC" <bc@freeuk.com> - 2011-11-09 16:53 +0000
                Re: Character Array vs String Willem <willem@toad.stack.nl> - 2011-11-09 17:05 +0000
                Re: Character Array vs String Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-09 08:54 -0800
                Re: Character Array vs String Tobias Blass <tobiasblass@gmx.net> - 2011-11-09 21:01 +0000
                Re: Character Array vs String "BartC" <bc@freeuk.com> - 2011-11-09 21:26 +0000
                Re: Character Array vs String Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-10 01:11 -0800
                Re: Character Array vs String David Thompson <dave.thompson2@verizon.net> - 2011-11-21 02:39 -0500
                Re: Character Array vs String Keith Thompson <kst-u@mib.org> - 2011-11-21 00:15 -0800
                Re: Character Array vs String Keith Thompson <kst-u@mib.org> - 2011-11-09 14:06 -0800
                Re: Character Array vs String Stephen Sprunk <stephen@sprunk.org> - 2011-11-09 19:32 -0600
                Re: Character Array vs String Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-10 03:21 +0000
                Re: Character Array vs String "BartC" <bc@freeuk.com> - 2011-11-10 11:00 +0000
                Re: Character Array vs String Keith Thompson <kst-u@mib.org> - 2011-11-10 03:26 -0800
                Re: Character Array vs String Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-10 12:04 +0000
                Re: Character Array vs String Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-21 12:02 -0800
                Re: Character Array vs String Kenneth Brody <kenbrody@spamcop.net> - 2011-11-23 11:42 -0500
                Re: Character Array vs String Uno <merrilljensen@q.com> - 2011-11-27 22:46 -0700
                Re: Character Array vs String Lew Pitcher <lpitcher@teksavvy.com> - 2011-11-27 23:30 -0800
                Re: Character Array vs String Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-11-28 00:22 -0800
        Re: Character Array vs String Keith Thompson <kst-u@mib.org> - 2011-11-09 13:59 -0800
    Re: Character Array vs String James Kuyper <jameskuyper@verizon.net> - 2011-11-09 08:36 -0500
      Re: Character Array vs String Quentin Carbonneaux <qcarbonn@invalid.com> - 2011-11-09 14:06 +0000
    Re: Character Array vs String Malcolm McLean <malcolm.mclean5@btinternet.com> - 2011-11-09 05:38 -0800
    Re: Character Array vs String Keith Thompson <kst-u@mib.org> - 2011-11-09 13:52 -0800
  Re: Character Array vs String Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-09 07:39 -0500
  Re: Character Array vs String "BartC" <bc@freeuk.com> - 2011-11-09 13:51 +0000
  Re: Character Array vs String John Bode <jfbode1029@gmail.com> - 2011-11-23 19:32 -0800
    Re: Character Array vs String James Kuyper <jameskuyper@verizon.net> - 2011-11-24 11:49 -0500

csiph-web