Skip to content

string.h

Methods

Return Method
void* memcpy( void *dest, const void *src, size_t n )
void* memmove( void *dest, const void *src, size_t n )
size_t strlen( const char *str )
int strcmp( const char *str1, const char *str2 )
char* strcpy( char *dest, const char *src )
char* strcat( char *dest, const char *src )
char* strrev( char *str )

Method Descriptions

void *memcpy( void *dest, const void *src, size_t n )
a.k.a. memory copy

Copies n bytes from src to dest. It is used to copy a block of memory from one location to another.

It does not check for overflow or \0, and may cause problems when src and dest addresses overlap.


void *memmove( void *dest, const void *src, size_t n )
a.k.a. memory move

Copies n bytes from src to dest. It is used to copy a block of memory from one location to another.

It copies data first from src to a buffer, then to dest, so it is safe to use when src and dest addresses overlap.


size_t strlen( const char *str )
a.k.a. string length

Returns the length from a string str up to but not including \0.


int strcmp( const char *str1, const char *str2 )
Compares chracters of string str1 to string str2 per index starting with the first character, until the corresponding characters differ or end of one of the strings is reached.

Refer to ASCII table for reference

return value condition
return < 0 str1 < str2
return == 0 str1 == str2
return > 0 str1 > str2

char *strcpy( char *dest, const char *src )
a.k.a. string copy

Copies the string from src to string pointer dest, Includes \0 at the end of the string.

Returns string pointer dest.


char *strcat( char *dest, const char *src )
a.k.a. string concatonate

Appends the string from src to the end of dest string.

Returns dest string pointer.


char *strrev( char *str )

Reverses the string.