Next Previous Contents

## 3.148 strdup

> Function

>   Allocate a copy of a string on the heap.

> Header

>   `string.h`

> Declaration

>   `char* __fastcall__ strdup (const char* s);`

> Description

>   `strdup` allocates a memory block on the heap, big enough to hold a copy of `s` including the terminating zero. If the allocation fails, `NULL` is returned, otherwise `s` is copied into the allocated memory block, and a pointer to the block is returned.

> Limits

>   - The function is only available as fastcall function, so it may only be used in presence of a prototype.
>   - It is up to the caller to free the allocated memory block.
> Availability

>   ISO 9899

> See also

>   free, malloc

> Example

>   None.

Next Previous Contents