SEEK_SET, SEEK_CUR, SEEK_END — seek origins
The SEEK_SET, SEEK_CUR, and SEEK_END macros select the reference point for fseek: the beginning, current position, or end of the file.
CKTIS / C
Programming syntax, operators and concepts. Find an explanation, explore an example and return to learning.
The SEEK_SET, SEEK_CUR, and SEEK_END macros select the reference point for fseek: the beginning, current position, or end of the file.
Macros from <stdint.h> describe integer ranges and bit widths. Use them to check portability and reject oversized calculations before evaluating them. C23 adds the macros ending in _WIDTH.
Macros from <stdio.h> select a stream's buffering mode and specify the buffer size for setbuf. Do not assume their numeric values.
FOPEN_MAX, FILENAME_MAX, L_tmpnam, and TMP_MAX describe distinct guarantees, not one file limit.
Pass a comparator as a typed function pointer, compare the full `int` range without overflow, and preserve the input order of records with equal keys.
Map operation IDs to function pointers, call the selected callback indirectly, and distinguish an invalid index from a valid slot with no handler.
Implement a fixed-capacity FIFO queue in an array using two indices and a count, so freed slots can be reused without shifting elements.
Search a tree of groups recursively by checking each group's own items first, then its subgroups, and optionally save a pointer to the group containing the first match.
Define a function pointer type for employee comparisons and indirectly call the four active comparators in an array with capacity for eight.
Define a function-pointer alias and use it to choose at runtime how `qsort` orders an array of employee records.
Implement a fixed-capacity FIFO queue and use `head`, `tail`, and `size` to reuse array slots without shifting elements.
Declare a function pointer type, pass a compatible comparator as a callback, and compare signed integer priorities safely even at the limits of `int`.
Read outward from the name to tell a variable that holds a comparator pointer from a function that returns one.
`int (*fn)(void)` declares a pointer to a function that takes no parameters and returns `int`. Use it to pass a test callback to `run_test`.
Pass a string-selection rule as a function pointer so the same filter can count matching strings first and then collect them in input order.
A LIFO stack removes the most recently pushed record first. Keep the element count separate from capacity and grow the buffer without losing data on allocation failure.
Use `*=` to multiply the current value and store the result in the same object. The left operand is evaluated once, but you still need a bounds check before doubling a capacity.
Move pointers in element-sized steps, use the one-past position safely, and compute signed differences that fit in `ptrdiff_t`.
Define `Predicate` as a function pointer type alias, then use an array of callbacks to check whether one order satisfies every rule or at least one rule.
A `Group` structure links to subgroups of its own type. A depth-first search checks local values first and can report which group contains the first match.
A tagged union pairs an `enum` field with a `union` payload. The tag tells you which alternative was stored and which member to read.
Name a function pointer type, then use it to pass strategies and predicates, return a selected function, or store callbacks in structs and arrays for later calls.
Unary minus negates an arithmetic operand after integer promotions. If the result type is unsigned, negation uses modular arithmetic. If it is a signed integer type, whether the negated value is representable depends on both the operand’s value and the type’s range.
After any applicable integer promotions, unary minus on a signed integer gives the arithmetic opposite if that value is representable in the promoted type; otherwise the behavior is undefined. For an unsigned promoted type, the result is computed modulo one more than the type’s maximum.