sqrt — square root
The sqrt function from <math.h> computes the nonnegative square root. It accepts and returns double; an argument less than zero causes a domain error.
CKTIS / C
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The sqrt function from <math.h> computes the nonnegative square root. It accepts and returns double; an argument less than zero causes a domain error.
srand seeds the pseudorandom sequence produced by rand. Reusing the same seed repeats the sequence within an implementation.
sscanf from <stdio.h> reads data from a null-terminated string according to a format. It stores results through pointers and returns the number of successful assignments (excluding `%n`), not the number of characters read.
static_assert checks a condition during compilation rather than program execution. In C23 it is a keyword, not a function; its message is optional.
strcat from <string.h> appends a source string to a destination string. It requires a sufficiently large buffer and does not check its capacity.
strchr finds the first occurrence of a character in a C string, returning a pointer or NULL.
strcmp compares the contents of two null-terminated strings. Its result describes equality or ordering.
strcpy copies a string including its terminating '\0'. The caller must provide enough destination space and ensure objects do not overlap.
strcspn returns the length of an initial string segment containing none of the characters in a second string. The size_t result is the index of the first match if one exists, or strlen(s1) if there is no match.
strdup creates an independent, writable string copy. Check for NULL and release the allocated memory with free.
strerror converts an error code to a message. The returned text depends on the implementation and locale.
strftime from <time.h> formats a struct tm into a buffer. The format controls the date and time representation; reserve space for the terminating null character.
strlen from <string.h> returns a string's length in bytes before the first '\0', excluding that terminator.
strncat appends at most n source bytes to a string and adds '\0'. The parameter n is not the destination buffer capacity.
strncmp compares at most n bytes, stopping at '\0'. Equal prefixes do not establish equality of entire strings.
strncpy writes n bytes, padding short input with zeros. It does not guarantee a '\0'-terminated result.
strndup creates an independent string from at most size initial characters of an array, adding a null terminator. Check the result and release it with free.
strpbrk finds the first character in a string that belongs to the character set supplied by another string. It returns a pointer to the match or NULL.
strrchr from <string.h> returns a pointer to the last occurrence of a character in a string, or NULL. The search includes the terminating '\0'.
strspn returns the length of the initial portion of a string containing only characters from a supplied set.
strstr from <string.h> finds the first substring and returns a pointer to it, or NULL.
strtod converts a string prefix to double. endptr lets you detect missing conversions and inspect the remaining text.
strtof reads the beginning of a string as float. The endptr pointer lets you detect missing conversion and remaining text.
strtok splits a writable string into nonempty tokens, overwriting delimiters and remembering where to continue.