On Sat, May 12, 2001 at 02:10:45AM -0400, Daniel Hemmerich wrote:
> Any comments, suggestions, swears concerning adding a new function, 
> strndup(), to libc?
> 
> So that instead of permitting it to attempt to allocate a large chunk of 
> memory, it is possible to give it a max length.

#include <stdio.h>

int main(int argc, char **argv) {
        char *p;

        asprintf(&p, "%.*s", 100, argv[1]);
        printf("%s %d\n", p, strlen(p));
}

Kris

PGP signature

Reply via email to