Re: DEC-C: Null string constant ?
From: David Froble (davef_at_tsoft-inc.com)
Date: 10/22/04
- Next message: reb: "Re: J F on why USA is a regime"
- Previous message: Daniel Gustafsson: "Re: Java JAR run across platforms, Zip exception"
- In reply to: briggs_at_encompasserve.org: "Re: DEC-C: Null string constant ?"
- Next in thread: JF Mezei: "Re: DEC-C: Null string constant ?"
- Reply: JF Mezei: "Re: DEC-C: Null string constant ?"
- Reply: Roy Omond: "Re: DEC-C: Null string constant ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 22 Oct 2004 02:55:03 -0400
briggs@encompasserve.org wrote:
> In article <4177CBED.40109@tsoft-inc.com>, David Froble <davef@tsoft-inc.com> writes:
>
>>JF Mezei wrote:
>>
>>
>>>char *mybuffer ;
>>>mybuffer = ""
>>>myroutine(mybuffer);
>>>
>>>----
>>>myroutine(char *mybuffer)
>>>{
>>>printf ("Address of string=>%ld\n", mybuffer);
>>>}
>>>
>>>Retults in a big fat value of 0, and of course, if you try to strlen(mybuffer)
>>>the program crashes.
>>>
>>>I was under the impression that "" yielded a valid string constant containing
>>>only the null character, and that you could use this to still provide a valid
>>>pointer address to the various routines in your applications.
>>>
>>
>>First note that my prefered language is BASIC, not C.
>>
>>A null is a valid character.
>>
>
> That statement is a tad strong. A null _can be_ a valid character.
To be a bit more precise, a null character is a valid character. ASCII value is
zero.
> Whether it is valid depends on context. It's a valid character
> in the ASCII code.
>
> But, if your context is a null-terminated string, then a null is not
> a valid character within the body of that string.
>
>
>>It takes one byte of storage for each character.
>>It is a bit tough to have a string of nulls when using null terminated strings.
>>
>
> Of course. As it happens, I find null-terminated strings distasteful
> as well. For this very reason.
>
> I have developed a distaste for VMS "can't be longer than 2^16 characters"
> string descriptors as well. It is a bit tough to encode a 100,000
> character string when strings are limited to 65535 characters.
I confess to curosity. What's the usage of such a long string?
> Ah well. Such is life. I don't much care for ASN.1 unlimited
> length encodings either. Guess there's no pleasing some people. :-)
>
>
>> Another shortcoming of that technique.
>>
>>A null string is a string with no characters, zero length.
>>
>
> True. And a null string encoded as a null-terminated string
> is a buffer containing a single null character.
>
> A null string encoded using a VMS descriptor is a quadword with a length
> code of zero and pointer that doesn't have to point anywhere special.
Well, you describe the descriptor, not the data. I've not looked, but I think
there might be a problem with a pointer to some location that will generate an
error, such as zero. Just guessing.
> A null string encoded as a counted string is a buffer containing
> a single zero byte.
>
> A null string encoded with ASN.1 is... I'd have to go look it
> up. *** sound of furious keyboard tapping *** ... A two byte
> buffer containing
>
> 0x4 (Universal, Primitive, Octet string)
> 0x0 (Short format, length 0)
> (String contents -- null)
>
> John Briggs
>
-- David Froble Tel: 724-529-0450 Dave Froble Enterprises, Inc. Fax: 724-529-0596 DFE Ultralights, Inc. E-Mail: davef@tsoft-inc.com 170 Grimplin Road Vanderbilt, PA 15486
- Next message: reb: "Re: J F on why USA is a regime"
- Previous message: Daniel Gustafsson: "Re: Java JAR run across platforms, Zip exception"
- In reply to: briggs_at_encompasserve.org: "Re: DEC-C: Null string constant ?"
- Next in thread: JF Mezei: "Re: DEC-C: Null string constant ?"
- Reply: JF Mezei: "Re: DEC-C: Null string constant ?"
- Reply: Roy Omond: "Re: DEC-C: Null string constant ?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|