string.h

This header contains all functions for handling text strings. Most of them are analogous to what a standard C compiler includes. Note however that, since Vircon32 cannot handle individual bytes, there is no type 'char' in this compiler. This implies that characters are represented as 'int', and pointers to strings are 'int*'


Character classification functions

Function: isdigit
Prototype: bool isdigit( int c )
Description: Determines if the given character is a digit (0-9)
Returns:
bool True if the character is a digit, false otherwise
Arguments:
int c The character to test
Function: isxdigit
Prototype: bool isxdigit( int c )
Description: Determines if the given character is a hexadecimal digit (0-9 + letters a-f or A-F)
Returns:
bool True if the character is a hexadecimal digit, false otherwise
Arguments:
int c The character to test
Function: isalpha
Prototype: bool isalpha( int c )
Description: Determines if the given character is a letter from the alphabet (a-z or A-Z)
Returns:
bool True if the character is a letter, false otherwise
Arguments:
int c The character to test
Function: isalphanum
Prototype: bool isalphanum( int c )
Description: Determines if the given character is alphanumerical (either a letter or a digit)
Returns:
bool True if the character is alphanumerical, false otherwise
Arguments:
int c The character to test
Function: isascii
Prototype: bool isascii( int c )
Description: Determines if the given character is from standard ASCII (codes 0 to 127)
Returns:
bool True if the character is standard ASCII, false otherwise
Arguments:
int c The character to test
Function: islower
Prototype: bool islower( int c )
Description: Determines if the given character is a lowercase letter (a-z)
Returns:
bool True if the character is a lowercase letter, false otherwise
Arguments:
int c The character to test
Function: isupper
Prototype: bool isupper( int c )
Description: Determines if the given character is an uppercase letter (A-Z)
Returns:
bool True if the character is an uppercase letter, false otherwise
Arguments:
int c The character to test
Function: isspace
Prototype: bool isspace( int c )
Description: Determines if the given character is whitespace (space, tab, line feed or carriage return)
Returns:
bool True if the character is whitespace, false otherwise
Arguments:
int c The character to test

Character conversion functions

Function: tolower
Prototype: int tolower( int c )
Description: Returns the lowercase equivalent of the given character. Non letters and lowercase letters are returned with no changes
Returns:
int The resulting lowercase character
Arguments:
int c The character to convert
Function: toupper
Prototype: int toupper( int c )
Description: Returns the uppercase equivalent of the given character. Non letters and uppercase letters are returned with no changes
Returns:
int The resulting uppercase character
Arguments:
int c The character to convert

String handling functions

Function: strlen
Prototype: int strlen( int* text )
Description: Returns the number of characters of a string, until a null termination is found
Returns:
int Number of characters of the given string
Arguments:
int* text Pointer to the null-terminated string to be measured
Function: strcmp
Prototype: int strcmp( int* text1, int* text2 )
Description: Compares 2 text strings and returns the relative alphabetical ordering
Returns:
int A positive value if text1 comes after text 2. Negative if text1 comes before text2. Zero when equal
Arguments:
int* text1 Pointer to first null-terminated string to compare
int* text2 Pointer to second null-terminated string to compare
Function: strncmp
Prototype: int strncmp( int* text1, int* text2, int max_characters )
Description: Same as strcmp, but it limits the number of compared characters
Returns:
int A positive value if text1 comes after text 2. Negative if text1 comes before text2. Zero when equal
Arguments:
int* text1 Pointer to first null-terminated string to compare
int* text2 Pointer to second null-terminated string to compare
int max_characters Maximum number of characters to compare. Has no effect if one of the strings is shorter
Function: strcpy
Prototype: void strcpy( int* dest_text, int* src_text )
Description: Copies the contents of the source string into the destination
Arguments:
int* dest_text Pointer to destination string (null-terminated)
int* src_text Pointer to source string (null-terminated)
Function: strncpy
Prototype: void strncpy( int* dest_text, int* src_text, int max_characters )
Description: Same as strcpy, but it limits the number of copied characters
Arguments:
int* dest_text Pointer to destination string (null-terminated)
int* src_text Pointer to source string (null-terminated)
int max_characters Maximum number of characters to copy. Has no effect if the source is shorter
Function: strcat
Prototype: void strcat( int* initial_text, int* added_text )
Description: Concatenates the contents of the added string at the end of the initial string
Arguments:
int* initial_text Pointer to initial string (null-terminated)
int* added_text Pointer to added string (null-terminated)
Function: strncat
Prototype: void strncat( int* initial_text, int* added_text, int max_characters )
Description: Same as strcat, but it limits the number of appended characters
Arguments:
int* initial_text Pointer to initial string (null-terminated)
int* added_text Pointer to added string (null-terminated)
int max_characters Maximum number of characters to append. Has no effect if the source is shorter

Conversion of numbers to string

Function: itoa
Prototype: void itoa( int value, int* result_text, int base )
Description: Converts the given integer into its string representation, using the given number base.
Arguments:
int value
int* result_text Pointer to the buffer that will store the result. Note that no length checks are performed
int base Number base (number of digits to use). Supported bases are 2 to 16
Function: ftoa
Prototype: void ftoa( float value, int* result_text )
Description: Converts the given float into its string representation. Note that exponential notation is currently not supported
Arguments:
float value The value to convert
int* result_text Pointer to the buffer that will store the result. Note that no length checks are performed