avr_string(3) <string.h>: Strings

Macros


#define _FFS(x)

Functions


char * strdup (const char *s1)

size_t strlcat (char *, const char *, size_t)

size_t strlcpy (char *, const char *, size_t)

char * strtok (char *, const char *)

Detailed Description

#include <string.h> 

The string functions perform string operations on NULL terminated strings.

Note:

If the strings you are working on resident in program space (flash), you will need to use the string functions described in <avr/pgmspace.h>: Program Space Utilities.

Macro Definition Documentation

#define _FFS(x)

This macro finds the first (least significant) bit set in the input value.

This macro is very similar to the function ffs() except that it evaluates its argument at compile-time, so it should only be applied to compile-time constant expressions where it will reduce to a constant itself. Application of this macro to expressions that are not constant at compile-time is not recommended, and might result in a huge amount of code generated.

Returns:

The _FFS() macro returns the position of the first (least significant) bit set in the word val, or 0 if no bits are set. The least significant bit is position 1. Only 16 bits of argument are evaluted.

Function Documentation

char * strdup (const char * s1)

Duplicate a string. The strdup() function allocates memory and copies into it the string addressed by s1, including the terminating null character.

Warning:

The strdup() function calls malloc() to allocate the memory for the duplicated string! The user is responsible for freeing the memory by calling free().

Returns:

The strdup() function returns a pointer to the resulting string dest. If malloc() cannot allocate enough storage for the string, strdup() will return NULL.

Warning:

Be sure to check the return value of the strdup() function to make sure that the function has succeeded in allocating the memory!

size_t strlcat (char * dst, const char * src, size_t siz)

Concatenate two strings. Appends src to string dst of size siz (unlike strncat(), siz is the full size of dst, not space left). At most siz-1 characters will be copied. Always NULL terminates (unless siz <= strlen(dst)).

Returns:

The strlcat() function returns strlen(src) + MIN(siz, strlen(initial dst)). If retval >= siz, truncation occurred.

size_t strlcpy (char * dst, const char * src, size_t siz)

Copy a string. Copy src to string dst of size siz. At most siz-1 characters will be copied. Always NULL terminates (unless siz == 0).

Returns:

The strlcpy() function returns strlen(src). If retval >= siz, truncation occurred.

char * strtok (char * s, const char * delim)

Parses the string s into tokens. strtok parses the string s into tokens. The first call to strtok should have s as its first argument. Subsequent calls should have the first argument set to NULL. If a token ends with a delimiter, this delimiting character is overwritten with a '\0' and a pointer to the next character is saved for the next call to strtok. The delimiter string delim may be different for each call.

Returns:

The strtok() function returns a pointer to the next token or NULL when no more tokens are found.

Note:

strtok() is NOT reentrant. For a reentrant version of this function see strtok_r().

Author

Generated automatically by Doxygen for avr-libc from the source code.