Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Languages Misc > Re: NUL to term...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 40 of 61 Topic 1118 of 1217
Post > Topic >>

Re: NUL to terminate strings; was reinventing ASCII?

by "Rod Pemberton" <do_not_have@[EMAIL PROTECTED] > Mar 10, 2008 at 07:26 PM

"James Harris" <james.harris.1@[EMAIL PROTECTED]
> wrote in message
news:44bf8f7a-c1f5-4dbb-a265-0542fdae3bf9@[EMAIL PROTECTED]
> On 10 Mar, 12:13, Ben Bacarisse <ben.use...@[EMAIL PROTECTED]
> wrote:
> > James Harris <james.harri...@[EMAIL PROTECTED]
> writes:
> > > On 8 Mar, 17:22, Ben Bacarisse <ben.use...@[EMAIL PROTECTED]
> wrote:
> > > ...
> > >> So they need a terminating character unless they are defined some
> > >> other way?  Surely the question was why were they not defined in
one
> > >> of these other ways?
> >
> > > Yes, I mean that to allow C strings to be defined as they are by a
> > > single pointer requires there to be a terminating character of some
> > > sort.
> >
> > But this is not true -- at least not literally true.  In BCPL strings
> > were represented by a single pointer, but that pointer was to a
> > length.  I am sure you are not unaware of this kind of representation,
> > I just think you are over-cooking the argument to come up with
> > "requires there to be a terminating character".  I see no such
> > requirement -- it could have been different.
> >
> > I suspect I am reading more into your statement than you intended.
>
> I see your point and appreciate being made to think this through more
> clearly.
> I suppose the bit missing from what I said above is that the
> C concept of a string being an array (of char) allows nowhere for a
> length prefix. If it is an array of char then all elements should be
> of type char.

A string can be an contiguous sequence of char - even with a length
prefix.
Whether it's C compliant is a separate issue.  The header containing the
length just needs to be placed prior to the address representing the start
of the string.

C normally:
----
item[0]  <-- i.e., C's "decayed" pointer points here, start of string data
item[1]
item[2]
item[3]
....
item[length]='\0'  <-- end of string data
....
item[size]  <-- end of allocation for string


In the style of PL/1:
----
length   <-- start of string data, first two items fixed size header
size
item[0]  <-- i.e., C's "decayed" pointer points here
item[1]
item[2]
item[3]
....
item[length-1]  <-- end of string data
item[length]     <-- implicit null character '\0' - not actually set to
null
character
....
item[size]  <-- end of allocation for string


Rod Pemberton
 




 61 Posts in Topic:
reinventing ASCII?
wildhalcyon <wild.halc  2008-03-03 05:56:01 
Re: reinventing ASCII?
"cr88192" <c  2008-03-04 05:35:03 
Re: reinventing ASCII?
"Rod Pemberton"  2008-03-03 15:13:13 
Re: reinventing ASCII?
Jacko <jackokring@[EMA  2008-03-03 12:58:14 
Re: reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-04 10:19:06 
Re: reinventing ASCII?
Eliot Miranda <eliotm@  2008-03-04 13:18:31 
Re: reinventing ASCII?
"Charlie Gordon"  2008-03-05 03:58:24 
Re: reinventing ASCII?
ram@[EMAIL PROTECTED] (S  2008-03-05 03:26:51 
Re: reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-05 10:31:40 
Re: reinventing ASCII?
Edward Feustel <efeust  2008-03-05 06:32:23 
Re: reinventing ASCII?
James Harris <james.ha  2008-03-05 15:05:37 
Re: reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-06 11:34:33 
Re: NUL to terminate strings; was reinventing ASCII?
James Harris <james.ha  2008-03-08 07:16:34 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-08 10:48:58 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-08 19:29:00 
Re: NUL to terminate strings; was reinventing ASCII?
Ulrich Eckhardt <dooms  2008-03-09 09:18:15 
Re: NUL to terminate strings; was reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-11 11:04:42 
Re: NUL to terminate strings; was reinventing ASCII?
santosh <santosh.k83@[  2008-03-11 16:26:16 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-11 11:10:37 
Re: NUL to terminate strings; was reinventing ASCII?
torbenm@[EMAIL PROTECTED]  2008-03-12 09:43:18 
Re: NUL to terminate strings; was reinventing ASCII?
santosh <santosh.k83@[  2008-03-12 14:25:04 
Re: NUL to terminate strings; was reinventing ASCII?
"Wilhelm B. Kloke&qu  2008-03-12 09:18:23 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-12 11:08:21 
Re: NUL to terminate strings; was reinventing ASCII?
"Wilhelm B. Kloke&qu  2008-03-12 12:33:14 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-12 14:11:25 
Re: NUL to terminate strings; was reinventing ASCII?
Chris Dollin <chris.do  2008-03-12 13:33:42 
Re: NUL to terminate strings; was reinventing ASCII?
"Wilhelm B. Kloke&qu  2008-03-12 15:34:40 
Re: NUL to terminate strings; was reinventing ASCII?
"Default User"   2008-03-12 18:22:45 
Re: NUL to terminate strings; was reinventing ASCII?
"Default User"   2008-03-12 18:22:45 
Re: NUL to terminate strings; was reinventing ASCII?
"Default User"   2008-03-11 21:26:05 
Re: NUL to terminate strings; was reinventing ASCII?
Micah Cowan <micah@[EM  2008-03-11 15:14:10 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-11 22:27:14 
Re: NUL to terminate strings; was reinventing ASCII?
Morris Dovey <mrdovey@  2008-03-08 09:45:05 
Re: NUL to terminate strings; was reinventing ASCII?
Ben Bacarisse <ben.use  2008-03-08 17:22:36 
Re: NUL to terminate strings; was reinventing ASCII?
billg999@[EMAIL PROTECTED  2008-03-08 18:27:46 
Re: NUL to terminate strings; was reinventing ASCII?
James Harris <james.ha  2008-03-09 17:16:03 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-10 01:08:23 
Re: NUL to terminate strings; was reinventing ASCII?
Ben Bacarisse <ben.use  2008-03-10 12:13:19 
Re: NUL to terminate strings; was reinventing ASCII?
James Harris <james.ha  2008-03-10 08:45:25 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-10 19:26:16 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-10 21:03:06 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-11 11:06:14 
Re: NUL to terminate strings; was reinventing ASCII?
CBFalconer <cbfalconer  2008-03-11 15:22:58 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <Eric.Sosm  2008-03-13 17:37:20 
Re: NUL to terminate strings; was reinventing ASCII?
rlb@[EMAIL PROTECTED] (R  2008-03-14 09:32:54 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-14 09:21:41 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-14 17:48:27 
Re: NUL to terminate strings; was reinventing ASCII?
Morris Dovey <mrdovey@  2008-03-10 10:35:21 
Re: NUL to terminate strings; was reinventing ASCII?
"Rod Pemberton"  2008-03-10 19:09:27 
Re: NUL to terminate strings; was reinventing ASCII?
Eric Sosman <esosman@[  2008-03-10 21:00:14 
Re: NUL to terminate strings; was reinventing ASCII?
Marco van de Voort <ma  2008-03-11 11:04:46 
Re: NUL to terminate strings; was reinventing ASCII?
billg999@[EMAIL PROTECTED  2008-03-11 12:04:26 
Re: NUL to terminate strings; was reinventing ASCII?
billg999@[EMAIL PROTECTED  2008-03-11 12:07:36 
Re: NUL to terminate strings; was reinventing ASCII?
Neilist <lattoralee@[E  2008-03-11 14:28:23 
Re: NUL to terminate strings; was reinventing ASCII?
richard@[EMAIL PROTECTED]  2008-03-11 22:22:36 
Re: NUL to terminate strings; was reinventing ASCII?
Richard <devr_@[EMAIL   2008-03-11 23:23:21 
Re: NUL to terminate strings; was reinventing ASCII?
Jacko <jackokring@[EMA  2008-03-12 11:49:33 
Re: NUL to terminate strings; was reinventing ASCII?
Micah Cowan <micah@[EM  2008-03-12 19:01:00 
Re: NUL to terminate strings
CBFalconer <cbfalconer  2008-03-10 17:35:16 
Re: NUL to terminate strings
rlb@[EMAIL PROTECTED] (R  2008-03-14 09:28:38 
Re: NUL to terminate strings; was reinventing ASCII?
BruceMcF <agila61@[EMA  2008-04-12 18:27:54 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Jul 25 18:15:29 CDT 2008.