Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

Knowledge base — C

Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.

Entries: 472

C

longjmp — C23 control-transfer function

`longjmp(env, val)` from `<setjmp.h>` restores the environment saved by the most recent `setjmp(env)` and does not return to its call site. The resumed `setjmp` returns `val`, or returns `1` when `val == 0`, so a jump remains distinguishable from the initial pass.

Advanced · C23
C

lround — C23 mathematical function

`lround(x)` from `<math.h>` rounds a `double` to the nearest `long int` value; an exact halfway case always moves away from zero, independently of the current rounding mode. The `lroundf` and `lroundl` variants accept `float` and `long double`, respectively.

Intermediate · C23
C

malloc — C23 memory-allocation function

`malloc(size)` from `<stdlib.h>` reserves space for an object of `size` bytes and returns a pointer to the start of a disjoint region, or a null pointer on failure. The new bytes have an indeterminate representation; unlike `calloc`, the function does not clear them.

Basic · C23
C

mbrtoc16 — C23 Unicode-conversion function

`mbrtoc16(pc16, s, n, ps)` from `<uchar.h>` examines at most `n` bytes of the next execution multibyte character and stores the corresponding UTF-16 `char16_t` code unit. The `mbstate_t` object designated by `ps` preserves conversion state between calls; `pc16 == NULL` suppresses only the output store.

Advanced · C23
C

mbrtoc32 — C23 Unicode-conversion function

`mbrtoc32(pc32, s, n, ps)` from `<uchar.h>` converts at most `n` bytes of the next execution multibyte character to a UTF-32 `char32_t` unit. Its `mbstate_t` state lets a character continue across buffer boundaries; a null `pc32` still performs conversion but suppresses the store.

Advanced · C23
C

mbrtoc8 — C23 Unicode-conversion function

`mbrtoc8(pc8, s, n, ps)` from C23 `<uchar.h>` converts the next execution multibyte character into successive UTF-8 `char8_t` code units; in C23, `char8_t` is the same type as `unsigned char`. It examines at most `n` bytes, while `mbstate_t` retains a partial character and pending units.

Advanced · C23
C

mbrtowc — C23 restartable multibyte conversion

`mbrtowc(pwc, s, n, ps)` from `<wchar.h>` examines at most `n` bytes of the next multibyte character in the current execution encoding. When a valid character is completed, it returns the number of bytes that completed it and stores the corresponding `wchar_t` if `pwc != NULL`; the `mbstate_t` at `ps` carries a character across buffer boundaries.

Advanced · C23
C

memchr — C23 generic byte search

The C23 generic function `memchr(s, c, n)` from `<string.h>` finds the first byte equal to `c` after conversion to `unsigned char` among the first `n` bytes of the object at `s`. It returns a pointer exactly to the first match or null; the implementation must behave as if it reads sequentially and stops immediately on a match.

Intermediate · C23
C

memcmp — C23 byte-representation comparison

`memcmp(s1, s2, n)` from `<string.h>` lexicographically compares the first `n` bytes of two object representations, interpreting every byte as `unsigned char`. It returns zero if all are equal; otherwise it returns a value whose sign is the difference of the first unequal pair. The sign, not the exact magnitude, is guaranteed.

Intermediate · C23
C

memcpy — C23 non-overlapping byte copy

`memcpy(s1, s2, n)` from `<string.h>` copies exactly `n` bytes of object representation from source `s2` to writable destination `s1` and returns the original value of `s1`. Bytes are interpreted as `unsigned char`; the function knows nothing about elements, array lengths, or text terminators.

Intermediate · C23
C

memmove — C23 overlap-safe byte copy

`memmove(s1, s2, n)` from `<string.h>` copies `n` bytes of representation from source to writable destination and returns the original `s1`. Unlike `memcpy`, its result is defined when the ranges overlap: semantics are as if the source bytes were first copied into a separate temporary array of `n` bytes.

Intermediate · C23
C

memset — filling memory with bytes

memset from <string.h> fills n bytes with c converted to unsigned char. It operates on bytes, not on the values of array elements.

Basic · C23; repository compiler flag, production runtime not attested
C

memset_explicit — explicit memory overwriting

The C23 function memset_explicit fills a specified memory region with a chosen byte. It is intended to erase sensitive data without the optimizer removing the write as an unnecessary operation.

Intermediate · C23; repository compiler flag, production runtime not attested
C

mktime — convert and normalize local time

mktime converts local time stored in struct tm into time_t, normalizing the fields on success.

Intermediate · C23; repository compiler flag, production runtime not attested
C

modf — splitting integral and fractional parts

The modf function from <math.h> returns the fractional part of a double and writes its integral part through a pointer. Both parts remain double values.

Basic · C23; repository compiler flag, production runtime not attested
C

mtx_destroy — release mutex resources

mtx_destroy from <threads.h> releases a mutex's resources. It returns no value; no thread may be blocked waiting for that mutex during destruction.

Intermediate · C23; repository compiler flag, production runtime not attested
C

mtx_init — initialize a mutex

mtx_init from <threads.h> initializes a mutex with selected properties. Check its result before using the object, and finish its lifecycle with mtx_destroy.

Intermediate · C23; repository compiler flag, production runtime not attested
C

mtx_lock — locking a mutex

mtx_lock waits to acquire a mutex. It returns thrd_success on success or thrd_error on failure.

Basic · C23; repository compiler flag, production runtime not attested
C

mtx_timedlock — lock a mutex with a deadline

`mtx_timedlock` attempts to lock a mutex by an absolute deadline based on `TIME_UTC`. It distinguishes successful acquisition, timeout, and error.

Intermediate · C23; repository compiler flag, production runtime not attested
C

mtx_unlock — unlock a mutex

mtx_unlock from <threads.h> unlocks a mutex owned by the calling thread and returns a success or error code.

Intermediate · C23; repository compiler flag, production runtime not attested
C

nearbyint — rounding using the current mode

nearbyint returns an integer-valued double using the current rounding direction without raising the inexact exception.

Intermediate · C23; repository compiler flag, production runtime not attested
C

perror — print the message corresponding to errno

perror from <stdio.h> prints a message for the current errno value to stderr, optionally preceded by your own description. It does not detect an error and returns no value.

Basic · C23; repository compiler flag, production runtime not attested
C

pow — exponentiation

The pow function from <math.h> computes x raised to y, accepting and returning double. Learn its syntax and its domain and range limitations.

Basic · C23; repository compiler flag, production runtime not attested