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

cnd_init — C23 condition-variable function

`cnd_init(cond)` creates a new condition variable and, on success, stores in `*cond` a value that uniquely identifies it. It returns `thrd_success`, `thrd_nomem` when memory cannot be allocated, or `thrd_error` when the request cannot be honored.

Intermediate · C23
C

cnd_signal — C23 condition-variable function

`cnd_signal(cond)` unblocks one thread blocked on `cond` at the time of the call. If there is no waiter, it still does nothing and returns `thrd_success`; otherwise the result is `thrd_success` or `thrd_error`.

Advanced · C23
C

cnd_timedwait — C23 condition-variable function

`cnd_timedwait(cond, mtx, ts)` atomically unlocks the owned `mtx` and waits for a signal/broadcast, the absolute `TIME_UTC` calendar time in `*ts`, or an unblock for an unspecified reason. Before a normal return it locks that mutex again.

Advanced · C23
C

cnd_wait — C23 wait function

`cnd_wait(cond, mtx)` from `<threads.h>` atomically unlocks the owned `mtx` and blocks until a signal, broadcast, or an unblock for an unspecified reason. Before returning it locks `mtx` again; the result is `thrd_success` or `thrd_error`.

Advanced · C23
C

copysign — C23 mathematical function

`copysign(x, y)` from `<math.h>` returns a value with the magnitude of `x` and the sign of `y`; when `x` is NaN, the result is a NaN with `y`’s sign. C23 says that if either value is unsigned, the result’s sign, if any, is implementation-defined.

Intermediate · C23
C

cos — C23 mathematical function

`cos(x)` from `<math.h>` computes the cosine of `x` measured in radians and returns `double`; `cosf` and `cosl` serve `float` and `long double`. For finite arguments, base C23 specifies no domain error.

Basic · C23
C

cosh — C23 mathematical function

`cosh(x)` from `<math.h>` returns the hyperbolic cosine of `x`, mathematically `(e^x + e^-x) / 2`. The function is even; C23 requires a range error when the magnitude of finite `x` is too large.

Intermediate · C23
C

ctime — deprecated C23 time function

`ctime(timer)` from `<time.h>` converts the pointed-to `time_t` calendar time to a local-time string and returns the pointer produced by the equivalent of `asctime(localtime(timer))`. In C23 its declaration is `[[deprecated]]`; the function is obsolescent and should be avoided in new code.

Intermediate · C23
C

difftime — C23 time function

`difftime(time1, time0)` from `<time.h>` computes `time1 - time0` for two `time_t` calendar times and returns the difference in seconds as `double`. It is the portable interface because the encoding of `time_t` is unspecified.

Intermediate · C23
C

div — C23 utility function

`div(numer, denom)` from `<stdlib.h>` computes integer quotient and remainder in one operation, returning `div_t` with `quot` and `rem`. Integer division truncates toward zero, and `numer == quot * denom + rem`.

Basic · C23
C

errno — C23 error macro

`errno` from `<errno.h>` is a macro expanding to a modifiable lvalue of type `int` with thread storage duration. It is neither a function nor a constant: use `errno`, never `errno()`, and every thread has its own object.

Intermediate · C23
C

exit — C23 termination function

`exit(status)` from `<stdlib.h>` causes normal program termination and does not return. It first calls `atexit` functions in reverse registration order, then flushes and closes streams, removes `tmpfile` files, and finally returns status to the host environment.

Advanced · C23
C

exp — C23 mathematical function

`exp(x)` from `<math.h>` computes the base-e exponential and returns `e^x` as `double`; `expf` and `expl` serve `float` and `long double`. C23 requires a range error when the magnitude of finite `x` is too large.

Intermediate · C23
C

exp2 — C23 mathematical function

`exp2(x)` from `<math.h>` computes `2^x` and returns it as `double`; `exp2f` and `exp2l` accept `float` and `long double`, respectively. C23 reports a range error when the magnitude of finite `x` is too large.

Intermediate · C23
C

expm1 — C23 mathematical function

`expm1(x)` from `<math.h>` computes `e^x - 1` as `double`; `expm1f` and `expm1l` serve `float` and `long double`. It is designed to retain accuracy for tiny `x`, where separately evaluating `exp(x) - 1` loses digits by subtracting nearby values.

Intermediate · C23
C

fabs — C23 mathematical function

`fabs(x)` from `<math.h>` returns the absolute value of a `double`; `fabsf` and `fabsl` serve `float` and `long double`. Unlike integer `abs`, it has no unrepresentable positive counterpart problem for the most negative integer.

Basic · C23
C

fclose — C23 stream function

`fclose(stream)` from `<stdio.h>` flushes the specified stream, delivers unwritten data to the host environment, discards unread input, closes the associated file, and disassociates the `FILE` object. It returns zero on success or `EOF` on failure.

Intermediate · C23
C

feof — C23 stream function

`feof(stream)` from `<stdio.h>` tests the end-of-file indicator belonging to an open `FILE` stream. It returns nonzero if and only if that indicator is set; it performs no read and does not return the `EOF` constant itself.

Basic · C23
C

ferror — C23 stream function

`ferror(stream)` from `<stdio.h>` tests the error indicator belonging to an open `FILE` stream. It returns nonzero if and only if that indicator is set; it performs no I/O, does not return a specific error code, and does not alter the stream state.

Basic · C23
C

fflush — C23 stream function

`fflush(stream)` from `<stdio.h>` delivers unwritten buffered data to the host environment for an output stream or a qualifying update stream. `fflush(NULL)` attempts this for every such open stream; the result is zero on success or `EOF` with the error indicator set on failure.

Intermediate · C23
C

fgetc — C23 stream function

`fgetc(stream)` from `<stdio.h>` reads the next character from an input stream, advances its position, and returns the byte interpreted as `unsigned char` and then converted to `int`. At end of file or on failure it returns `EOF` and sets the corresponding stream indicator.

Basic · C23
C

fgetpos — C23 stream function

`fgetpos(stream, pos)` from `<stdio.h>` stores an open stream’s current position state in the `fpos_t` object designated by `pos`. It returns zero on success and nonzero on failure; the saved state is intended for a later `fsetpos`.

Intermediate · C23
C

fgets — C23 stream function

`fgets(s, n, stream)` from `<stdio.h>` reads at most `n - 1` characters into array `s`, stopping after a newline has been read or at end of file. A read newline remains in the array, and the function appends `\0` after the characters obtained.

Basic · C23
C

floor — C23 mathematical function

`floor(x)` from `<math.h>` returns the greatest integral floating value not greater than `x`; the result still has type `double`. `floorf` and `floorl` serve `float` and `long double`, and the environment rounding direction does not change this contract.

Basic · C23