Re: strcat strncat and strlen



Bill Cunningham wrote:

Strncat is supposed
to be better than strcat for some reason I've read.
Is this because of a potential buffer overflow?

Probably better to read the some reason again
and then ask again if you still have questions.

I have compiled properly and used strlen too
and I just wonder what is the need to return a strlen?

Has anyone used quite abit anyway the strlen function?

It's handy for allocations for strings.

http://www.mindspring.com/~pfilandr/C/lists_and_files/string_sort.c

tail = list_append(&head, tail, *ptr, strlen(*ptr) + 1);


http://www.mindspring.com/~pfilandr/C/lists_and_files/list_lib.c

list_type *list_append
(list_type **head, list_type *tail, void *data, size_t size)
{
list_type *node;

node = malloc(sizeof *node);
if (node != NULL) {
node -> next = NULL;
node -> data = malloc(size);
if (node -> data != NULL) {
memcpy(node -> data, data, size);
if (*head != NULL) {
tail -> next = node;
} else {
*head = node;
}
} else {
free(node);
node = NULL;
}
}
return node;
}

--
pete
.



Relevant Pages

  • Re: CD Sales Down
    ... maybe if I'd set reason aside one time and went with my feeling that one time might have worked. ... Evidence is used to convince someone who DOESN'T already believe. ... entered the guy's head. ... there are all sorts of regulations about secondary usage of tech related to a whole host of items - being able to take something apart and rebuild it into something else. ...
    (alt.guitar)
  • Re: CFB National title game...
    ... DOMINATED/HUMILIATED Vatech in the head to head matchup is the reason ... but the fact that the game was at the beginning of the ... scenario of the computer rankings. ...
    (rec.gambling.sports)
  • Re: Outline > approx. word count?
    ... because she does that part in her head. ... years, except for the two books that didn't have any outlines at all, the ... Which might be a good reason *not* to write them down, ... writing-out prose phase) if I feel that the situation set-up and ...
    (rec.arts.sf.composition)
  • Re: Is there a correct place to put javascript within a html file?
    ... The HTML specification tells you where script elements are permitted: ... script files have downloaded and if they're all in the head ... ... like the sensible thing to do; at least there's a reason for it. ... javascript is positioned just before the then the various html ...
    (comp.lang.javascript)
  • Re: Dr. Atkins Dietetic Revolution: Mu Critique?
    ... You claimed some reason to believe a ... > working in a law office with a couple hundred lawyers, ... > committees that included US Attorneys (one of whom became head of the ... > DEA and a judge and another who became head of the FBI), ...
    (sci.med.cardiology)