Re: strcat strncat and strlen
- From: pete <pfiland@xxxxxxxxxxxxxx>
- Date: Sun, 30 Mar 2008 20:57:05 -0500
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
.
- References:
- strcat strncat and strlen
- From: Bill Cunningham
- strcat strncat and strlen
- Prev by Date: Re: Doubts about pointers
- Next by Date: Re: interesting examples to learn C.
- Previous by thread: Re: strcat strncat and strlen
- Next by thread: Hot Pregnant Woman
- Index(es):
Relevant Pages
|
|