GitOS
Operating system exercise
Loading...
Searching...
No Matches
string.h File Reference
#include <stddef.h>
#include <stdarg.h>

Go to the source code of this file.

Functions

size_t strlen (const char *str)
 Determine the length of a string.
 
size_t strnlen (const char *str, size_t max_len)
 Determine the length of a fixed-size string.
 
char * strcpy (char *dest, const char *src)
 Copies string.
 
char * strncpy (char *dest, const char *src, size_t n)
 Copies string with maximum length.
 
char * strrev (char *str)
 Reverses string.
 
int strncmp (const char *str1, const char *str2, size_t n)
 Compares two strings with maximum length.
 
int strcmp (const char *str1, const char *str2)
 Compares two strings.
 
size_t strnlen_terminator (const char *str, size_t max, char terminator)
 Calculates string length with custom terminator.
 
int istrncmp (const char *str1, const char *str2, size_t n)
 
char tolower (char c)
 Converts ASCII letter to lowercase.
 
char * itoa (long num, char *str, int base)
 Converts signed number to string.
 
char * uitoa (unsigned long num, char *str, int base)
 Converts unsigned number to string.
 
char * sprintf (char *buf, const char *fmt,...)
 Kernel sprintf params: %% c s p l(mod) d i x.
 
char * vsprintf (char *buf, const char *fmt, va_list args)
 Kernel vsprintf params: %% c s p l(mod) d i x.
 
int is_digit (char c)
 Determines if given char is an ASCII digit.
 
int to_numeric_digit (char c)
 Converts ASCII digit to numeric.
 
void * memset (void *ptr, int c, size_t size)
 Sets first bytes of memory pointed to specified value.
 
void * memcpy (void *dstptr, const void *srcptr, size_t size)
 Copies memory from one place to another.
 
int memcmp (void *ptr1, void *ptr2, size_t len)
 Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2.
 

Function Documentation

◆ is_digit()

int is_digit ( char  c)

Determines if given char is an ASCII digit.

Parameters
cCharacter to test
Returns
int 1 if given char is digit

◆ istrncmp()

int istrncmp ( const char *  str1,
const char *  str2,
size_t  n 
)

References tolower().

◆ itoa()

char * itoa ( long  num,
char *  str,
int  base 
)

Converts signed number to string.

Parameters
numLong to convert
strBuffer
baseBase to use when converting the number
Returns
char* Buffer

References base, and strrev().

◆ memcmp()

int memcmp ( void *  ptr1,
void *  ptr2,
size_t  len 
)

Compares the first num bytes of the block of memory pointed by ptr1 to the first num bytes pointed by ptr2.

Parameters
ptr1Pointer to block of memory
ptr2Pointer to block of memory
lenNumber of bytes to compare
Returns
int
  • 0 if matches,
  • -1 the first byte that does not match in both memory blocks has a lower value in ptr1 than in ptr2,
  • 1 the first byte that does not match in both memory blocks has a greater value in ptr1 than in ptr2

◆ memcpy()

void * memcpy ( void *  dstptr,
const void *  srcptr,
size_t  size 
)

Copies memory from one place to another.

Parameters
dstptrDestination pointer
srcptrSource pointer
sizeLength of copied memory
Returns
void* Destination pointer

References size.

◆ memset()

void * memset ( void *  ptr,
int  c,
size_t  size 
)

Sets first bytes of memory pointed to specified value.

Parameters
ptrPointer to the block of memory to fill
cValue to be set
sizeNumber of bytes to set
Returns
void* Pointer to the block of memory

References size.

◆ sprintf()

char * sprintf ( char *  buf,
const char *  fmt,
  ... 
)

Kernel sprintf params: %% c s p l(mod) d i x.

Parameters
bufBuffer
fmtText to format
...Args
Returns
char* Buffer

References vsprintf().

◆ strcmp()

int strcmp ( const char *  str1,
const char *  str2 
)

Compares two strings.

Parameters
str1String
str2String
Returns
int 0 -> str1==str2, <0 -> str1<str2, >0 ->str1>str2

References strlen(), and strncmp().

◆ strcpy()

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

Copies string.

Parameters
destDestination buffer
srcInput buffer
Returns
char* Pointer to destination buffer

◆ strlen()

size_t strlen ( const char *  str)

Determine the length of a string.

Parameters
strString
Returns
size_t Length

◆ strncmp()

int strncmp ( const char *  str1,
const char *  str2,
size_t  n 
)

Compares two strings with maximum length.

Parameters
str1String
str2String
nMax length
Returns
int 0 -> str1==str2, <0 -> str1<str2, >0 ->str1>str2

◆ strncpy()

char * strncpy ( char *  dest,
const char *  src,
size_t  n 
)

Copies string with maximum length.

Parameters
destDestination buffer
srcInput buffer
nMax length
Returns
char* Pointer to destination buffer

◆ strnlen()

size_t strnlen ( const char *  str,
size_t  max_len 
)

Determine the length of a fixed-size string.

Parameters
str
max_len
Returns
size_t

◆ strnlen_terminator()

size_t strnlen_terminator ( const char *  str,
size_t  max,
char  terminator 
)

Calculates string length with custom terminator.

Parameters
strString to measure length
maxMax length of string
terminatorCustom terminator
Returns
int Length

◆ strrev()

char * strrev ( char *  str)

Reverses string.

Parameters
strString to reverse
Returns
char* str

References strlen().

◆ to_numeric_digit()

int to_numeric_digit ( char  c)

Converts ASCII digit to numeric.

Parameters
cASCII digit
Returns
int Numeric digit

◆ tolower()

char tolower ( char  c)

Converts ASCII letter to lowercase.

Parameters
cInput letter
Returns
char Lowercase letter

◆ uitoa()

char * uitoa ( unsigned long  num,
char *  str,
int  base 
)

Converts unsigned number to string.

Parameters
numUnsigned Long to convert
strBuffer
baseBase to use when converting the number
Returns
char* Buffer

References base, and strrev().

◆ vsprintf()

char * vsprintf ( char *  buf,
const char *  fmt,
va_list  args 
)

Kernel vsprintf params: %% c s p l(mod) d i x.

Parameters
bufBuffer
fmtText to format
va_listarguments
Returns
char* Buffer

References itoa(), memcpy(), memset(), strlen(), and uitoa().