GBDK 2020 Docs  4.1.1
API Documentation for GBDK 2020
string.h File Reference
#include <types.h>

Go to the source code of this file.

Functions

char * strcpy (char *dest, const char *src) OLDCALL PRESERVES_REGS(b
 
int strcmp (const char *s1, const char *s2) OLDCALL PRESERVES_REGS(b
 
void * memcpy (void *dest, const void *src, size_t len)
 
void * memmove (void *dest, const void *src, size_t n)
 
void * memset (void *s, int c, size_t n) OLDCALL PRESERVES_REGS(b
 
char * reverse (char *s) OLDCALL PRESERVES_REGS(b
 
char * strcat (char *s1, const char *s2)
 
int strlen (const char *s) OLDCALL PRESERVES_REGS(b
 
char * strncat (char *s1, const char *s2, int n)
 
int strncmp (const char *s1, const char *s2, int n)
 
char * strncpy (char *s1, const char *s2, int n)
 
int memcmp (const void *buf1, const void *buf2, size_t count) OLDCALL
 

Variables

char c
 

Detailed Description

Generic string functions.

Function Documentation

◆ strcpy()

char* strcpy ( char *  dest,
const char *  src 
)

Copies the string pointed to by src (including the terminating ‘\0’ character) to the array pointed to by dest.

The strings may not overlap, and the destination string dest must be large enough to receive the copy.

Parameters
destArray to copy into
srcArray to copy from
Returns
A pointer to dest

◆ strcmp()

int strcmp ( const char *  s1,
const char *  s2 
)

Compares strings

Parameters
s1First string to compare
s2Second string to compare

Returns:

  • > 0 if s1 > s2
  • 0 if s1 == s2
  • < 0 if s1 < s2

◆ memcpy()

void* memcpy ( void *  dest,
const void *  src,
size_t  len 
)

Copies n bytes from memory area src to memory area dest.

The memory areas may not overlap.

Parameters
destBuffer to copy into
srcBuffer to copy from
lenNumber of Bytes to copy

◆ memmove()

void* memmove ( void *  dest,
const void *  src,
size_t  n 
)

Copies n bytes from memory area src to memory area dest, areas may overlap

◆ memset()

void* memset ( void *  s,
int  c,
size_t  n 
)

Fills the memory region s with n bytes using value c

Parameters
sBuffer to fill
cchar value to fill with (truncated from int)
nNumber of bytes to fill

◆ reverse()

char* reverse ( char *  s)

Reverses the characters in a string

Parameters
sPointer to string to reverse.

For example 'abcdefg' will become 'gfedcba'.

Banked as the string must be modifiable.

Returns: Pointer to s

◆ strcat()

char* strcat ( char *  s1,
const char *  s2 
)

Concatenate Strings. Appends string s2 to the end of string s1

Parameters
s1String to append onto
s2String to copy from

For example 'abc' and 'def' will become 'abcdef'.

String s1 must be large enough to store both s1 and s2.

Returns: Pointer to s1

◆ strlen()

int strlen ( const char *  s)

Calculates the length of a string

Parameters
sString to calculate length of

Returns: Length of string not including the terminating ‘\0’ character.

◆ strncat()

char* strncat ( char *  s1,
const char *  s2,
int  n 
)

Concatenate at most n characters from string s2 onto the end of s1.

Parameters
s1String to append onto
s2String to copy from
nMax number of characters to copy from s2

String s1 must be large enough to store both s1 and n characters of s2

Returns: Pointer to s1

◆ strncmp()

int strncmp ( const char *  s1,
const char *  s2,
int  n 
)

Compare strings (at most n characters):

Parameters
s1First string to compare
s2Second string to compare
nMax number of characters to compare

Returns zero if the strings are identical, or non-zero if they are not (see below).

Returns:

  • > 0 if s1 > s2 (at first non-matching byte)
  • 0 if s1 == s2
  • < 0 if s1 < s2 (at first non-matching byte)

◆ strncpy()

char* strncpy ( char *  s1,
const char *  s2,
int  n 
)

Copy n characters from string s2 to s1

Parameters
s1String to copy into
s2String to copy from
nMax number of characters to copy from s2

If s2 is shorter than n, the remaining bytes in s1 are filled with \0.

Warning: If there is no \0 in the first n bytes of s2 then s1 will not be null terminated.

Returns: Pointer to s1

◆ memcmp()

int memcmp ( const void *  buf1,
const void *  buf2,
size_t  count 
)

Compare up to count bytes in buffers buf1 and buf2

Parameters
buf1Pointer to First buffer to compare
buf2Pointer to Second buffer to compare
countMax number of bytes to compare

Returns zero if the buffers are identical, or non-zero if they are not (see below).

Returns:

  • > 0 if buf1 > buf2 (at first non-matching byte)
  • 0 if buf1 == buf2
  • < 0 if buf1 < buf2 (at first non-matching byte)

Variable Documentation

◆ c

void c