Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

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

 
 
Programmer Dude
Guest
Posts: n/a
 
      09-05-2003
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 <(E-Mail Removed)> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
 
Reply With Quote
 
 
 
 
pete
Guest
Posts: n/a
 
      09-06-2003
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
 
Reply With Quote
 
 
 
 
Programmer Dude
Guest
Posts: n/a
 
      09-08-2003
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 <(E-Mail Removed)> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
 
Reply With Quote
 
pete
Guest
Posts: n/a
 
      09-09-2003
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
 
Reply With Quote
 
Programmer Dude
Guest
Posts: n/a
 
      09-09-2003
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 <(E-Mail Removed)> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      09-09-2003
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
 
Reply With Quote
 
Programmer Dude
Guest
Posts: n/a
 
      09-09-2003
Default User wrote:

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


Who said anything about intrinsic?

--
|_ CJSonnack <(E-Mail Removed)> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      09-09-2003
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
 
Reply With Quote
 
Programmer Dude
Guest
Posts: n/a
 
      09-09-2003
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 <(E-Mail Removed)> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
 
Reply With Quote
 
Default User
Guest
Posts: n/a
 
      09-09-2003
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VOIP over VPN over TCP over WAP over 3G Theo Markettos UK VOIP 2 02-14-2008 03:27 PM
LOOK! i just want to know does anyone know... Simon Egginton Javascript 3 07-26-2004 08:11 PM
Need a logical flow of javascript calls to execute like I want them... can't figure it out. Matthew Javascript 3 02-10-2004 06:21 PM
Printer problem-- can anyone figure this out? MB Computer Support 0 12-10-2003 11:19 PM
Re: Anyone want to look over my C code for me? I can't figure it out... Arthur J. O'Dwyer C Programming 6 09-06-2003 05:01 AM



Advertisments