Re: C (functional programming) VS C++ (object oriented programming)



jacob navia wrote:

santosh wrote:
jacob navia wrote:

Richard Heathfield wrote:
jacob navia said:
H. is arguing that strncmp is not a string comparison function.
Heathfield
That's right.
[snip]

Yes, I agree that it's a comparison function. So what?

OK. I give up.

Are you really saying you don't know the difference between a comparison
function and string comparison function?

The crucial difference between strcmp and strncmp is that the former
_needs_ it's arguments to be null-terminated strings while the latter
doesn't. There is a crucial difference between an array of characters,
(which needn't, but could be, a string), and a string.


Look:

1) The standard names EXPLICITELY strncmp a "comparison functions" in
the section String handling.
2) strncmp starts with the prefix "str"
3) Contrary to memcmp, strncmp will STOP the comparison at a zero byte,
i.e. it has STRING SEMANTICS!

Yes, but it doesn't _require_ it's arguments to be strings.

But you go on telling that it is not a string comparison function.

At the very least I'd say it's a sub-string comparison function.

<snip>

.



Relevant Pages

  • Re: C (functional programming) VS C++ (object oriented programming)
    ... The crucial difference between strcmp and strncmp is that the former _needs_ ... needn't, but could be, a string), and a string. ... But you go on telling that it is not a string comparison function. ...
    (comp.lang.c)
  • Re: sorting dates
    ... >The string method runs about 60 times faster, so if speed does matter, ... Your date array appears to hold entries such as 13-Apr-05. ... Your string sort first converts those to 2005-04-13 (the hyphens are a ... Object array, and use a comparison function that subtracts the Objects, ...
    (comp.lang.javascript)
  • RE: Combined natural and unnatural list sorting
    ... > I looked for a while at using comparison functions with sort but I ... Of course a comparison function will work - you just have to write it ... I'll using DSU for this example. ... Split the string into two parts. ...
    (comp.lang.python)
  • Re: portability and small glitch in predicates
    ... The string= comparison function is defined as: ... (Self slap in the face.) ...
    (comp.lang.scheme)
  • Re: help developing function
    ... I now have to write a comparison function that when ... given two pointers to Digital_camera objects decides which of the two should ... Where megapixels are the same, ... string fourth = b.getMake; ...
    (comp.lang.cpp)