"lallous" <lallous@lgwm.org> wrote in message news:<2qde7uFttarhU1@uni-berlin.de>...[color=blue]
> "Stefan Schwärzler" <stefan.sa.schwaerzler_usenet@bmw.de> wrote in message
> news:chrpdl$j8k1@usenet.bmw.de...[color=green]
> > Hi Ng,
> > habe nicht besonders viel Erfahrung in C und C++, deshalb:
> > möchte den befehl strdup in <string.h> verwenden.
> >
> > #include <string.h>
> > attrib(char *name, char *val) : name(strdup(name)), val(strdup(val)),
> > next(0) {
> > CDEBUG(printf("attrib::attrib(%s, %s)\n", name, val));
> > }
> >
> > Borland bringt dann die Meldung "undefinierte Funktion" 'strdup'
> > Müsste doch in string.h definiert sein. Oder macht hier Borland was
> > anderes.
> >
> > Danke für Eure Hilfe,
> >[/color]
>
> Apparently, Borland C++ doesn't define strdup(), simply write it as:
>
> char *strdup( const char *s )
> {
> char *dup = malloc(strlen(s) +1);
> return strcpy(dup, s);
> }[/color]
That's C, in C++ better use std::string or if you think
it's really needed provide a wrapper class to avoid
confusion of operator new[]/delete[] (C++) with malloc/free (C).
[snip]
Stephan Brönnimann
broeni@osb-systems.com
Open source rating and billing engine for communication networks.