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

ABI and representation — concept C23

An ABI is the binary contract between separately compiled parts: calling convention, type sizes and alignment, structure layout, and data representation. The C standard defines no single ABI; linking objects built with incompatible options, packing, or calling conventions can corrupt arguments and memory.

Intermediate · C23
C

program architecture — concept C23

Program architecture separates responsibilities into header interfaces, translation-unit implementations, and explicit data-ownership rules. Boundaries should limit dependencies and hide state; global state and cyclic dependencies make testing, initialization, and safe resource release harder.

Intermediate · C23
C

asynchrony and concurrency — concept C23

C concurrency uses threads, mutexes, condition variables, and atomic objects, while asynchronous signal handlers have a much narrower set of permitted operations. A data race occurs when two conflicting actions are performed by different threads, at least one is non-atomic, and neither happens before the other; the behavior is undefined. `volatile` replaces neither atomics nor a lock.

Intermediate · C23
C

Binary search and lower bound in C

Binary search halves a sorted search range repeatedly. The example implements lower bound: the index of the first element not less than the key, or n if none exists. It covers duplicates, empty input, and safe midpoint calculation.

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

bit manipulation — concept C23

Bit operations act on integer representations, and unsigned types are the safest choice for masks. `CHAR_BIT` gives the number of bits in a byte; a negative shift count or one not smaller than the promoted left operand width is undefined, and shifting a negative signed value also needs special care.

Intermediate · C23
C

collections — concept C23

C has no standard dynamic containers: a collection is built from arrays, structures, pointers, and explicitly stored length or capacity. Every operation must preserve `length <= capacity`, valid index bounds, and buffer ownership; growth through `realloc` needs a temporary pointer so failure does not lose the original allocation.

Intermediate · C23
C

comments and documentation — concept C23

C supports block comments `/* ... */` and line comments `// ...`; comments disappear during an early translation phase, and block comments cannot nest. Documentation should record contracts and reasons for constraints rather than repeat obvious code.

Intermediate · C23
C

conditional control flow — concept C23

`if` selects a branch from a scalar value: zero and a null pointer are false, other values true; `switch` compares a promoted integer value with `case` labels. `&&` and `||` short-circuit, but side effects inside conditions obscure sequencing and should be made explicit.

Intermediate · C23
C

data processing pipelines — concept C23

A C data pipeline is an explicit sequence of read, validation, transformation, aggregation, and write stages, usually passing buffers and error codes between functions. Every stage should state memory ownership, accepted sizes, and partial-result handling so a failure cannot leave inconsistent state.

Intermediate · C23
C

declarations and linkage — concept C23

A declaration binds an identifier to a type, scope, and linkage; a definition additionally provides the object or function body. `extern` can declare a definition in another translation unit, file-scope `static` gives internal linkage, and complex declarators are read outward from the name.

Intermediate · C23
C

Depth-first search (DFS) in C

Depth-first search (DFS) explores the next branch of a graph before returning to the remaining neighbors. The example demonstrates recursive traversal, visited-vertex marking, and a deterministic printing order.

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

error handling — concept C23

C has no exceptions: functions report failure through a return value, output parameter, stream state, or `errno` only when their contract says so. Code must test the signal before using a result, preserve `errno` when needed, release partially acquired resources, and not mistake every boundary value for an error.

Intermediate · C23
C

expressions and operators — concept C23

An expression computes a value and may cause side effects; precedence and associativity determine grouping but do not generally determine operand evaluation order. Integer promotions, usual arithmetic conversions, and sequencing matter because unsequenced modifications of one object can be undefined.

Intermediate · C23
C

filtering and transformations — concept C23

Filtering retains elements that satisfy a predicate, while transformation produces a new value from each element; in C these are usually explicit loops or functions accepting a callback. Output size, in-place support, buffer overlap, and failure behavior must be part of the contract.

Intermediate · C23
C

finite state machines — concept C23

A finite-state machine models allowed states with an `enum` and events as validated explicit transitions; every state-event pair should define a next state or an error. An unhandled enumeration value, accidental `switch` fall-through, or changing state before a side effect succeeds creates invalid transitions.

Intermediate · C23
C

functions and parameters — concept C23

A function has a declared result type and typed parameter list; arguments pass by value, so modifying the caller’s object requires a valid pointer. A compatible prototype must be visible before the call, recursion needs a terminating case, and a returned pointer must not designate an expired automatic object.

Intermediate · C23
C

generic selection — concept C23

A `_Generic` expression selects an association from the type of its controlling expression without evaluating that expression; the result has the selected expression’s value and type. The list cannot contain two compatible types, at most one association may match, and no match requires `default`; check qualifier and conversion rules for the selected C revision.

Intermediate · C23
C

input output and serialization — concept C23

Standard I/O uses `FILE` objects with an open mode, position, and error/end indicators; the number of successfully processed items is part of the result. Text and binary serialization require size, encoding, byte-order, and short-read/write checks; external data must never become a format string.

Intermediate · C23
C

iterators and generators — concept C23

C defines neither generators nor an iterator protocol, so iteration is modeled with pointer-and-end pairs or a cursor structure and `next` function. The contract must distinguish end from failure, keep the collection alive for the traversal, and forbid dereferencing an end cursor.

Intermediate · C23
C

linear search — concept C23

Linear search examines elements in order and stops at the first match; for `n` elements it performs up to `n` comparisons, giving O(n) time and constant extra space. The result must distinguish index zero from no match, and the comparison must respect each element’s type and validity.

Intermediate · C23
C

Longest increasing subsequence (LIS)

LIS is the longest strictly increasing subsequence that preserves input order without requiring adjacent elements. The C example computes its length using dynamic programming in O(n²) time with O(n) auxiliary space.

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

loops and iteration — concept C23

`for`, `while`, and `do` loops repeat a statement while a scalar condition is true; `break` exits the nearest loop and `continue` advances to its next iteration step. Bounds must prevent array overrun and counter overflow, and the condition must ensure progress even for empty input.

Intermediate · C23
C

memory ownership and copies — concept C23

C requires explicit ownership: an automatic object lives to block exit, a static object for the program, and a dynamic allocation from successful allocation to exactly one `free`. Copying bytes does not copy resources referenced by fields, overlapping regions require `memmove`, and use-after-free, double free, or access outside an object is undefined.

Intermediate · C23
C

modules and boundaries — concept C23

C23 still organizes programs mainly with headers and separately translated source files: a header exposes declarations and one unit provides each externally linked definition. Include guards prevent repeated content, `static` hides implementation details, and incompatible declarations across units violate the contract.

Intermediate · C23