Common Abbreviations Used in C Programming

A reference of common abbreviations used when naming source code identifiers like variables, functions, and macros in the C programming language.

Introduction

Cryptic abbreviations should be avoided in identifiers to ensure source code remains readable. However, completely avoiding abbreviations often results in verbose code that obscures intent.

The following list contains common abbreviations suitable for C source code. These abbreviations may also be used in other programming languages, provided they do not conflict with established naming conventions.

In the provided examples, multiple words in an identifier are concatenated with underscores (_), as seen in the function name get_address. The underscore may be omitted if the identifier is short and consists of abbreviations (e. g., err_msg vs. errmsg) or a word combined with an abbreviation.

List of Abbreviations

arg, args
argument. Used to refer to arguments, such as the command line arguments passed to a C program’s int main(int argc, char *argv[]) function.
buf
buffer. Example: Variable used as a buffer, e. g., char buf[20].
c
count. Used in variable names as a suffix to indicate that a variable contains the number of certain items, such as in the argc (argument count) parameter of a C program’s main function.
cat
category. Example: Variable term_cat, function find_cat.
cmd, CMD
command. Example: Definition #define CMD_OPEN 1.
dst, dest
destination. Example: Variable used as a destination of an operation, e. g., char dst[40].
err, ERR
error. Used as a variable containing an error code, such as err or as prefix for definitions of error codes, such as ERR_INVALID_VALUE. In the C standard library the error stream is named stderr.
ex, ext
extended, extension. Used to mark a function with extended functionality, e. g., replace_ex.
i
index. Example: Variable iend.
i, j, k
index. Loop counter variables.
id
identifier. Unique identifier used to reference a certain record. Example: Variable user_id.
len
length. Example: Variable file_len, definition LEN_MAX.
max, MAX
maximum. Used in variable names, constants, or definitions, e. g., INT_MAX.
mem
memory. Example: Variable mem_size.
min, MIN
minimum. See max, MAX.
msg
message. Example: Variable err_msg.
num, NUM
number, number of items. Used for numbered items, such as the variable room_num, or in macro definitions, such as #define NUM_ROOMS 24.
opt, opts
option. Example: Variable compile_opts.
p, ptr
pointer. Used as a suffix for a variable or parameter name, such as memptr or memp, to indicate that the variable is intended for pointer arithmetic as opposed to a simple reference to an entity.
pos
position. Example: Variable start_pos.
prev
previous. Used in contexts such as prev and next to indicate the previous element.
retval
return value. Used as a variable name to store a function’s return value.
s
Plural. Appended to indicate a plural, e. g., args, opts.
src
source. Example: Variable used as the source of a copy operation, e. g., char *src = "Hello".
std
standard. Used in the C standard library, e. g., in header filenames such as stdlib.h or in stream names such as stdin.
v, val
value. Used to indicate a value, e. g., in (key, val) or (k, v) pairs, or as a suffix indicating that a variable contains values, such as the char *argv[] (argument values) parameter of a C program’s main function.
var
variable.