Re: Anyone want to look over my C code for me? I can't figure it out...

Discussion in 'C Programming' started by Programmer Dude, Sep 5, 2003.

  1. pete wrote:

    >> Just another data point... I prefer to use NULL for pointer types
    >> and 0 for scalars as a form of self-documentation.

    >
    > I think you mean "arithmetic types" instead of "scalars".


    I actually did mean scalars, although arithmetic would probably
    have been a better choice. Setting a string to "0" doesn't make
    a whole lot of sense! (-:

    (Hold over from working with languages recently that make a primary
    division between scalars and lists.)

    > Why isn't this thread in clc ?


    Don' know.

    > Followup set to clc.


    comp.prog restored (for now :).

    --
    |_ CJSonnack <> _____________| How's my programming? |
    |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
    |_____________________________________________|_______________________|
    Programmer Dude, Sep 5, 2003
    #1
    1. Advertising

  2. Programmer Dude

    pete Guest

    Programmer Dude wrote:
    >
    > pete wrote:
    >
    > >> Just another data point... I prefer to use NULL for pointer types
    > >> and 0 for scalars as a form of self-documentation.

    > >
    > > I think you mean "arithmetic types" instead of "scalars".

    >
    > I actually did mean scalars, although arithmetic would probably
    > have been a better choice. Setting a string to "0" doesn't make
    > a whole lot of sense! (-:


    In C, pointer types are scalars,
    which is why it's awkward to say that you would do one thing
    for pointer types and another for scalars.
    The other kind of scalars in C, are the arithmetic types.

    N869
    6.2.5 Types
    [#21] Integer and floating types are collectively called
    arithmetic types. Arithmetic types and pointer types are
    collectively called scalar types. Array and structure types
    are collectively called aggregate types.

    --
    pete
    pete, Sep 6, 2003
    #2
    1. Advertising

  3. pete wrote:

    >> I actually did mean scalars, although arithmetic would probably
    >> have been a better choice. Setting a string to "0" doesn't make
    >> a whole lot of sense! (-:

    >
    > In C, pointer types are scalars,
    > which is why it's awkward to say that you would do one thing
    > for pointer types and another for scalars.
    > The other kind of scalars in C, are the arithmetic types.


    Yes, of course. I eliminated pointers from scalars by mentioning
    them explicitly, and as I said last post, I was trying to distinquish
    between *list* types and, um, scalar types, but didn't switch mental
    gears well enough.

    The point I don't want to get lost is this:
    I use NULL when I want to assign to a pointer,
    0 when I want to assign to a numeric type,
    and "" when I want to assign to a string type.

    (In all cases assuming a default initial "empty" value.)

    --
    |_ CJSonnack <> _____________| How's my programming? |
    |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
    |_____________________________________________|_______________________|
    Programmer Dude, Sep 8, 2003
    #3
  4. Programmer Dude

    pete Guest

    Programmer Dude wrote:

    > string type.


    I think you mean just "string."

    "pointer to a string" is used in C89, and defined in C99,
    but string, isn't a type in C.

    --
    pete
    pete, Sep 9, 2003
    #4
  5. pete wrote:

    >> string type.

    >
    > I think you mean just "string."
    >
    > "pointer to a string" is used in C89, and defined in C99,
    > but string, isn't a type in C.


    No. I don't. YOU guys might be talking C only, but I'm talking
    more a general approach (note the crosspost; I'm in cp). There
    are, for instance, in C++ the same sort of types: pointers, scalars
    (usually arithmetic and excluding pointers) and string TYPES.

    The point is choosing an initializer that is appropriate and which
    participates in documenting the code.

    --
    |_ CJSonnack <> _____________| How's my programming? |
    |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
    |_____________________________________________|_______________________|
    Programmer Dude, Sep 9, 2003
    #5
  6. Programmer Dude

    Default User Guest

    Programmer Dude wrote:

    > No. I don't. YOU guys might be talking C only, but I'm talking
    > more a general approach (note the crosspost; I'm in cp). There
    > are, for instance, in C++ the same sort of types: pointers, scalars
    > (usually arithmetic and excluding pointers) and string TYPES.



    There is no string type in C++. There is an instantiated template class
    called string, provided in the Standard Library, but there is no
    intrinsic string type. It is not part of the C++ language.




    Brian Rodenborn
    Default User, Sep 9, 2003
    #6
  7. Default User wrote:

    > ...there is no intrinsic string type. It is not part of the C++
    > language.


    Who said anything about intrinsic?

    --
    |_ CJSonnack <> _____________| How's my programming? |
    |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
    |_____________________________________________|_______________________|
    Programmer Dude, Sep 9, 2003
    #7
  8. Programmer Dude

    Default User Guest

    Programmer Dude wrote:
    >
    > Default User wrote:
    >
    > > ...there is no intrinsic string type. It is not part of the C++
    > > language.

    >
    > Who said anything about intrinsic?



    If it isn't intrinic, then it isn't a part of the language. It's a
    library feature. C could have a string "type" just as easily, with no
    change to the language.




    Brian Rodenborn
    Default User, Sep 9, 2003
    #8
  9. Default User wrote:

    >>> ...there is no intrinsic string type. It is not part of the C++
    >>> language.

    >>
    >> Who said anything about intrinsic?

    >
    > If it isn't intrinic, then it isn't a part of the language. It's a
    > library feature. C could have a string "type" just as easily, with
    > no change to the language.


    Absolutely! What makes you think anyone said otherwise?

    --
    |_ CJSonnack <> _____________| How's my programming? |
    |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
    |_____________________________________________|_______________________|
    Programmer Dude, Sep 9, 2003
    #9
  10. Programmer Dude

    Default User Guest

    Programmer Dude wrote:
    >
    > Default User wrote:
    >
    > >>> ...there is no intrinsic string type. It is not part of the C++
    > >>> language.
    > >>
    > >> Who said anything about intrinsic?

    > >
    > > If it isn't intrinic, then it isn't a part of the language. It's a
    > > library feature. C could have a string "type" just as easily, with
    > > no change to the language.

    >
    > Absolutely! What makes you think anyone said otherwise?



    "There are, for instance, in C++ the same sort of types: pointers,
    scalars
    (usually arithmetic and excluding pointers) and string TYPES."


    If you didn't mean to include string with the other intrinsic types you
    listed, you should have made that clear.




    Brian Rodenborn
    Default User, Sep 9, 2003
    #10
  11. Default User wrote:

    > If you didn't mean to include string with the other intrinsic types
    > you listed, you should have made that clear.


    What, and miss out on this delightful conversation? :-\

    --
    |_ CJSonnack <> _____________| How's my programming? |
    |_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
    |_____________________________________________|_______________________|
    Programmer Dude, Sep 10, 2003
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arthur J. O'Dwyer
    Replies:
    6
    Views:
    323
    Richard Heathfield
    Sep 6, 2003
  2. Steve
    Replies:
    0
    Views:
    516
    Steve
    Sep 25, 2006
  3. Taras_96
    Replies:
    3
    Views:
    317
    Taras_96
    Jan 29, 2008
  4. Matthew
    Replies:
    3
    Views:
    83
    Matthew
    Feb 10, 2004
  5. Simon Egginton

    LOOK! i just want to know does anyone know...

    Simon Egginton, Jul 26, 2004, in forum: Javascript
    Replies:
    3
    Views:
    167
    Dr John Stockton
    Jul 26, 2004
Loading...

Share This Page