Reference

Reference

97 C entries with syntax, owning header, C standard version, and examples, sorted alphabetically.

#
_BoolC99's _Bool normalizes scalars to 0 for zero and 1 for nonzero. stdbool.h supplies bool, true, and false; cond…
_ComplexC99's _Complex supports float, double, and long double real/imaginary parts. complex.h provides I, creal, and…
_ImaginaryC99's optional _Imaginary is often unsupported. Portable code uses double _Complex, checks implementation macr…
_AtomicC11 _Atomic declares atomic types; data-race safety requires correct atomic operations, not stdatomic.h alone.…
_NoreturnC11's _Noreturn marks nonreturning functions. It is a contract, not termination; returning is undefined, and c…
_AlignasC11 _Alignas accepts a constant expression or type name to request valid alignment for an object or struct mem…
_AlignofC11's _Alignof returns a complete type's alignment as size_t for type names, not expressions. Arrays yield ele…
_GenericC11's _Generic selects by converted type at compile time. Control is unevaluated; selection determines value a…
_Static_assert_Static_assert checks an integer constant expression; zero fails with a message. Runtime values such as variab…
_Thread_localC11's _Thread_local creates an initialized, thread-lifetime copy per thread. It combines with static or extern…
#define#define creates object-like or function-like macros expanded before compilation, not function calls. Parenthes…
#include#include inserts a header or source text into the translation unit. Search order is implementation-defined; in…
#ifdef#ifdef includes code when an identifier is defined as a macro. Even #define FLAG 0 satisfies the condition; us…
#ifndef#ifndef includes code when an identifier is not defined as a macro. Even #define FLAG 0 makes the condition fa…
#endif#endif closes the nearest open #if, #ifdef, or #ifndef group. It takes no condition or semicolon; nested group…
#if#if evaluates an integer constant expression: nonzero includes code. Undefined identifiers become 0; variables…
#else#else is the fallback when no earlier branch is selected. A group allows one #else, after any #elif and before…
#elif#elif adds branches tested in order. Only the first true branch is included; the rest are skipped. A group may…
#undef#undef removes a macro, so #ifdef treats it as undefined and no replacement occurs. It is permitted even if th…
#pragma#pragma provides implementation-defined instructions. Unknown pragmas are ignored; portable code cannot rely o…
#error#error forces a diagnostic and stops translation, often with #if for invalid configurations. Compiler wording…
#line#line sets presumed line numbers and optional file names for later source, affecting __LINE__, __FILE__, and d…
A
autoauto gives locals automatic storage, their C89 default. Each block or recursive entry creates objects; file sc…
atoi()atoi() converts a decimal prefix to int and returns 0 if no conversion can be performed. Invalid input looks l…
atof()atof() parses a floating-point prefix and returns 0.0 if no conversion can be performed. Invalid input looks l…
B
breakbreak exits the nearest loop or switch. It leaves one level and cannot exit ordinary if; in switch, it prevent…
bsearch()bsearch() binary-searches an array sorted with its comparator, returning a match or NULL. Which duplicate matc…
C
charchar represents characters and defines C's byte: sizeof(char) is 1, but CHAR_BIT need not be 8. The three char…
constconst bars lvalue modification; pointer-to-const differs from const pointer. It implies no read-only storage,…
casecase needs an integer constant expression, converted to the switch's promoted type; no duplicates. const varia…
continuecontinue starts the nearest loop's next iteration, only in while, do, or for. for runs its step, while and do…
calloc()calloc() zero-initializes bytes or returns NULL. All-bits-zero need not represent null pointers or floating-po…
C escape sequences: controls, quotes, and numeric escapesC escapes denote characters in character constants and string literals. Octal escapes use up to three digits;…
Complete C89 operator precedence and associativity tableC precedence groups operators; associativity sets grouping at equal levels. The table lists 15 C89 levels, but…
C89 fundamental types: minimum ranges and precisionC types have minimum integer ranges and floating-point precision, not fixed widths. Use limits.h, float.h, siz…
D
doubledouble has at least float's precision and range. Unsuffixed literals are double; 64-bit IEEE 754 is common. Ap…
defaultdefault labels one optional switch branch for unmatched values; it can sit anywhere and fall through. Without…
dodo while tests after the body, so it runs at least once and suits retries. Nonzero repeats, continue reaches t…
E
externextern declares external names. Uninitialized file-scope objects are not defined; sharing needs one matching d…
elseelse handles false branches; else if chains conditions. It pairs with the nearest unmatched if, cannot stand a…
enumenum defines integer constants for constant expressions, incrementing from 0 or set values. Names share one na…
exit()exit() terminates normally without returning, flushing and closing streams. Use EXIT_SUCCESS or EXIT_FAILURE;…
F
floatfloat is single-precision, often 32-bit IEEE 754, not mandated. f suffix avoids double; approximation makes ==…
forfor's sections are optional except semicolons; a missing condition is true, and continue runs the step. C99 al…
fprintf()fprintf() applies printf() formatting to a writable stream and returns the character count. Match types; check…
fopen()fopen() opens a file in a specified mode and returns a FILE pointer, or NULL on failure. Use b for binary and…
fclose()fclose() flushes and closes a stream, returning 0 on success or EOF on error. Check delayed write failures; ne…
fgetc()fgetc() returns an unsigned char as int, or EOF at end-of-file or on error. Store it in int; use feof() and fe…
fputc()fputc() writes c to a stream as unsigned char, returning its int value or EOF on failure. It can write a null…
fgets()fgets() reads at most n-1 characters, keeps any newline, and adds a null terminator. It returns str, or NULL i…
fputs()fputs() writes a string without its null terminator and adds no newline. It returns nonnegative or EOF; buffer…
fread()fread() counts complete fixed-size elements read, not bytes. Short counts can mean EOF or error and omit parti…
fwrite()fwrite() writes fixed-size elements and returns the complete-element count; short counts indicate error. Struc…
free()free() releases dynamic storage; free(NULL) does nothing. Never access freed storage or free it twice; aliases…
G
gotogoto jumps to a same-function label, useful for cleanup but easy to abuse. Variably modified scopes impose res…
I
intint is a signed integer, commonly 32 bits but guaranteed only -32767..32767. See INT_MIN and INT_MAX; signed o…
ifif runs one statement when a scalar condition is nonzero. Braces group code; else and else if handle alternati…
inlineC99's inline suggests expansion without guaranteeing it or speed. static inline gives internal linkage and avo…
isalpha()isalpha() returns nonzero for a letter in the current locale. Pass EOF or unsigned char; it does not decode UT…
isdigit()isdigit() returns nonzero for decimal digits 0-9. Pass EOF or unsigned char; it tests one character, not an in…
L
longlong means long int, with at least int's range and -2147483647..2147483647. It may be 32 or 64 bits, uses L li…
M
malloc()malloc() allocates uninitialized storage and returns a pointer, or NULL on failure. Check size multiplication…
P
printf()printf() writes formatted output to stdout and returns the character count, excluding the null terminator. Typ…
printf format specifiersprintf specifiers control conversions, width, precision, and layout. Match them to promoted argument types; pr…
Q
qsort()qsort() sorts an array in place using a consistent, transitive comparator. Stability is not guaranteed; avoid…
R
registerregister suggests registers for locals, without a guarantee. It forbids & and file scope; compilers decide, so…
restrictC99's restrict promises exclusive object access during association, enabling optimization. Overlaps violating…
returnreturn ends the function and gives control to its caller. Results convert to the declared return type; void fu…
realloc()realloc() resizes and may move a block; use a temporary pointer. Failure with size > 0 preserves it; new bytes…
rand()rand() returns a pseudo-random integer from 0 through RAND_MAX. Sequences are implementation-specific; avoid m…
S
staticstatic gives locals static storage, initialized once. File-scope names get internal linkage; block static lack…
shortshort means short int, covering at least -32767..32767, commonly 16 bits. It combines with unsigned; promotion…
signedsigned int equals int, but signed char differs from char. Query SCHAR_MIN and INT_MIN for limits; signed overf…
switchswitch selects a case by integer value, or default. Fall-through can share code or surprise; break or return e…
structstruct groups members of different types in declaration order. Use . or ->; padding may make sizeof(struct) ex…
sizeofsizeof returns byte counts as size_t without array decay. It is usually compile-time; C99 VLAs may evaluate at…
scanf()scanf() returns EOF if an input failure occurs before the first conversion (if any) has completed. Bound %s/sc…
sprintf()sprintf() formats text into an array and appends a null terminator excluded from its count. It has no capacity…
strtol()strtol() converts a prefix to long in base 0 or 2-36 and reports the stop position. Clear errno, then check en…
srand()srand() seeds rand(); identical seeds reproduce sequences only within one implementation. Seed once, not in a…
strlen()strlen() counts characters before the null terminator as size_t. Unterminated input causes undefined behavior;…
strcpy()strcpy() copies src and its null terminator to dest. Ensure strlen(src)+1 bytes fit; unterminated sources or o…
strncpy()strncpy() copies at most n characters. If src reaches n, no terminator is added; append one when needed. Overl…
strcat()strcat() appends src over the old terminator and writes a new one. The buffer needs both lengths plus one byte…
strcmp()strcmp() compares unsigned char values and returns negative, zero, or positive. Only the sign matters; it is c…
strncmp()strncmp() compares at most n characters as unsigned chars, stopping at a difference or null. Zero means compar…
strchr()strchr() finds the first c, including the null terminator, returning a pointer or NULL. Check before dereferen…
strstr()strstr() finds the first case-sensitive match, returning a pointer inside haystack or NULL. An empty needle re…
scanf format specifier quick referencescanf specifiers set conversions, pointer types, and read limits. Use matching pointers, allow for null termin…
T
typedeftypedef aliases a type to simplify declarations. It creates no new type or safety, obeys scope and declaration…
toupper()toupper() maps lowercase to uppercase in the current locale, leaving others unchanged. Pass EOF or unsigned ch…
tolower()tolower() maps uppercase to lowercase in the current locale, leaving others unchanged. Pass EOF or unsigned ch…
U
unsignedunsigned means unsigned int for nonnegative values. It wraps modulo 2^N for N value bits, so UINT_MAX + 1u is…
unionunion members share one address. Writes change the active member; other reads are restricted. Size fits the la…
V
voidvoid is incomplete and valueless, for functions with no result or parameters. void * addresses only objects; d…
volatilevolatile suits device registers. Signal-handler sharing requires volatile sig_atomic_t, not any volatile objec…
W
whilewhile tests a scalar condition before each pass; false initially means zero iterations. Ensure the condition c…

❓ FAQ

QIs there a quick reference sheet for C on this site?
AYes. This hub collects 97 entries: 44 keywords, 36 standard-library functions, 12 preprocessor directives, plus 5 cheat sheets (printf/scanf specifiers, escape sequences, operator precedence, data-type ranges). Use the A-Z index or the category filter to jump straight to an entry.
QWhich C standard does this reference follow?
AEvery entry carries a standard badge and coverage spans C89 through C23. The badge marks the standard that introduced the feature; the notes point out later changes and compiler-specific behavior.
QCan I run the examples on this page?
AYes. Entries with a runnable example embed a GCC-backed editor: edit the snippet and press Run. The output printed under the example is the expected result.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

Content reviewed by MOTO · Found an error? Report it

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏