HELP PLEASE - How to convert string to byte array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lawrence Kirby

    #16
    Re: HELP PLEASE - How to convert string to byte array

    On Sat, 11 Jun 2005 23:44:45 +0000, pete wrote:
    [color=blue]
    > Lawrence Kirby wrote:
    >[color=green]
    >> Note that in the description above there is no
    >> such thing in C as a "byte
    >> object" (objects always have a type),
    >> a char object is a byte *sized* object.[/color]
    >
    > An allocated object doesn't always have a type.[/color]

    An allocated object is a grey area. The definition of the term "object"
    says it is a region of data storage then contents of which can represent
    values. Well a value in an object is an interpretation of a bit pattern
    according to the rules of a type - if you have no type you can't represent
    values.

    Lawrence

    Comment

    • pete

      #17
      Re: HELP PLEASE - How to convert string to byte array

      Lawrence Kirby wrote:[color=blue]
      >
      > On Sat, 11 Jun 2005 23:44:45 +0000, pete wrote:
      >[color=green]
      > > Lawrence Kirby wrote:
      > >[color=darkred]
      > >> Note that in the description above there is no
      > >> such thing in C as a "byte
      > >> object" (objects always have a type),
      > >> a char object is a byte *sized* object.[/color]
      > >
      > > An allocated object doesn't always have a type.[/color]
      >
      > An allocated object is a grey area.[/color]

      Not really.
      In C99 there's 3 kinds of durations for objects,
      and allocated is one of them.
      [color=blue]
      > The definition of the term "object"
      > says it is a region of data storage then contents of which
      > can represent values.[/color]

      It can represent values,
      as long as you do what takes to get the values in there.

      An uninitialised object of type int,
      can't represent values either,
      but it's still an object.
      [color=blue]
      > Well a value in an object is
      > an interpretation of a bit pattern
      > according to the rules of a type
      > - if you have no type you can't represent values.[/color]

      *Until* you have a type, you can't represent values.

      malloc returns the address of an object with indeterminate value.

      --
      pete

      Comment

      • Tim Rentsch

        #18
        Re: HELP PLEASE - How to convert string to byte array

        Lawrence Kirby <lknews@netacti ve.co.uk> writes:
        [color=blue]
        > On Sat, 11 Jun 2005 23:44:45 +0000, pete wrote:
        >[color=green]
        > > Lawrence Kirby wrote:
        > >[color=darkred]
        > >> Note that in the description above there is no
        > >> such thing in C as a "byte
        > >> object" (objects always have a type),
        > >> a char object is a byte *sized* object.[/color]
        > >
        > > An allocated object doesn't always have a type.[/color]
        >
        > An allocated object is a grey area. The definition of the term "object"
        > says it is a region of data storage then contents of which can represent
        > values. Well a value in an object is an interpretation of a bit pattern
        > according to the rules of a type - if you have no type you can't represent
        > values.[/color]

        Any object that is designated has a type, which is the type of the
        expression used to designate it; section 6.3.2.1 p1.

        Any object that is accessed has an effective type, which if it isn't
        anything else is the type of the lvalue used to access it; section
        6.5 p6.

        Some objects have an "inherent type" in the sense that the memory
        corresponds to (an instance of) a declared variable, and the variable
        has a type. This "inherent type" shows up tacitly in the language of
        6.5 p6, eg, "the declared type of the object, if any" (despite
        effective type being defined only when accessing objects, and despite
        the small inconsistency that variables, not objects, have a type
        declared for them). Section 6.5 p6 specifically anticipates the
        circumstance that an object not have an "inherent type", eg, "If a
        value is stored into an object having no declared type ...".

        Section 6.5 p7 imposes requirements on the relationship between the
        type of an object (that was designated) and the effective type of an
        object (that was accessed). Apparently there are no requirements
        imposed on the relationship between type and effective type (or
        "inherent type" for that matter), except in the case of access.

        The language in the standard is confused about what the word "object"
        means. It's defined (3.14) as 'a region of data storage in the
        execution environment', but in lots of places in the text of the
        standard it's used to mean something more like "an instance of a
        variable". There is the example language above, talking about the
        'declared type of the object', despite there being no definition of
        what the "declared type" of an object is (at least not that I could
        find). Also, although I don't have a reference, I'm pretty sure
        I remember seeing a phrase like "an instance of the object", which
        I took to mean that it's being used basically as a synonym for
        variable.

        To respond to the comment above - whenever an object is designated it
        has a type, which is the type of the expression used to designate the
        object; it is this type that is used to interpret what value might
        be represented.

        A region of storage need not have any type. Whenver that region of
        storage takes part in a computation, a type is imposed on it by the
        expression used to access it.

        Comment

        Working...