\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{geo.dj} \pdfinfo{ /Title (c-programming.pdf) /Creator (Cheatography) /Author (geo.dj) /Subject (C Programming Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{007FFF} \definecolor{LightBackground}{HTML}{EFF7FF} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{C Programming Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{geo.dj} via \textcolor{DarkBackground}{\uline{cheatography.com/164912/cs/34552/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}geo.dj \\ \uline{cheatography.com/geo-dj} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 9th October, 2022.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{4} \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Console Input/Output}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`\#include \textless{}stdio.h\textgreater{}` \{\{ac\}\}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{{\bf{Formatted Data}}} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `scanf()` & Read value/s (type defined by format string) into variable/s (type must match) from the input stream. Stops reading at the first whitespace. `\&` prefix not required for arrays (including strings.) (unsafe) \tn % Row Count 13 (+ 11) % Row 3 \SetRowColor{white} `printf()` & Prints data (formats defined by the format string) as a string to the output stream \tn % Row Count 18 (+ 5) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{Alternative} \tn % Row Count 19 (+ 1) % Row 5 \SetRowColor{white} `fgets(strName, length, stdin); sscanf();` & Uses fgets to limit the input length, then uses sscanf to read the resulting string in place of scanf. (safe) \tn % Row Count 25 (+ 6) % Row 6 \SetRowColor{LightBackground} {\bf{Characters}} \{\{bt=1\}\} & \{\{bt=1\}\} \tn % Row Count 27 (+ 2) % Row 7 \SetRowColor{white} `getchar()` & Returns a single character's ANSI code from the input stream buffer as an integer. (safe) \tn % Row Count 32 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.7165 cm} x{1.7165 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Console Input/Output (cont)}} \tn % Row 8 \SetRowColor{LightBackground} `putchar(int)` & Prints a single character from an ANSI code {\emph{integer}} to the output stream buffer. \tn % Row Count 5 (+ 5) % Row 9 \SetRowColor{white} {\bf{Strings}} \{\{bt=1\}\} & \{\{bt=1\}\} \tn % Row Count 6 (+ 1) % Row 10 \SetRowColor{LightBackground} `fgets(strName, length, stdin);` & Reads a line from the input stream into a string variable. (Safe) \tn % Row Count 10 (+ 4) % Row 11 \SetRowColor{white} `puts("string") ` & Prints a string to the output stream. \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.13289 cm} x{2.30011 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Data Types}} \tn % Row 0 \SetRowColor{LightBackground} Basic Data Type & Floating-point, integer, double, character \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Derived Data Type & Union, structure, array, etc \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Enumerated Data Type & Enums \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Void Data Type & Empty Value \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Boolean Type & True or False \tn % Row Count 9 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{0.84924 cm} p{0.36396 cm} x{1.8198 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{Primary Data Types}} \tn % Row 0 \SetRowColor{LightBackground} Integer & `int` & Storing Whole Numbers \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Character & \seqsplit{`char`} & Refers to all ASCII character sets and single alphabets \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} Long & \seqsplit{`long`} & Long integer \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} Floating point & \seqsplit{`float`} & Refer to all the real number value or decimal point \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} Double (Long float) & \seqsplit{`double`} & Include all large type of numeric that do not come under floating point or integer \tn % Row Count 14 (+ 4) % Row 5 \SetRowColor{white} Void & \seqsplit{`void`} & No value \tn % Row Count 16 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{0.85825 cm} x{2.57475 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Derived Data Types}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Data Type}} & {\bf{Description}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Arrays & A Sequence of a finite number of data items \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Function & A self-contained block of single or multiple statements. \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Pointers & Special form of variables for holding other variables' addresses. \tn % Row Count 9 (+ 3) % Row 4 \SetRowColor{LightBackground} Unions & The memory that we allocate to the largest data type gets reused for all the other types present in the group. \tn % Row Count 13 (+ 4) % Row 5 \SetRowColor{white} \seqsplit{Structures} & A collection of various different types of data type items \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.61351 cm} x{1.81949 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Standard Library Functions}} \tn % Row 0 \SetRowColor{LightBackground} `\#include\textless{}...\textgreater{}`\{\{nobreak\}\} \{\{bb=1\}\} & \{\{bb=1\}\} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{Header File}} & {\bf{Description}} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `stdio.h` & Standard input/output header file \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} `conio.h` & Console input/output header file \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} `string.h` & String related functions are defined in this header file \tn % Row Count 10 (+ 3) % Row 5 \SetRowColor{white} `string.h` & Contains general functions used in C \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} `math.h` & All math related functions are defined here \tn % Row Count 15 (+ 3) % Row 7 \SetRowColor{white} `time.h` & Contains time and clock related functions \tn % Row Count 17 (+ 2) % Row 8 \SetRowColor{LightBackground} `ctype.h` & All character handling functions are defined here \tn % Row Count 20 (+ 3) % Row 9 \SetRowColor{white} `stdarg.h` & Variable argument functions are declared here \tn % Row Count 23 (+ 3) % Row 10 \SetRowColor{LightBackground} `signal.h` & Signal handling functions are declared here \tn % Row Count 26 (+ 3) % Row 11 \SetRowColor{white} `setjmp.h` & Includes all jump functions \tn % Row Count 28 (+ 2) % Row 12 \SetRowColor{LightBackground} `locale.h` & Includes locale functions \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.61351 cm} x{1.81949 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Standard Library Functions (cont)}} \tn % Row 13 \SetRowColor{LightBackground} `errno.h` & Includes error handling functions \tn % Row Count 2 (+ 2) % Row 14 \SetRowColor{white} `assert.h` & Includes diagnostic functions \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{2.02547 cm} x{1.40753 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Commenting}} \tn % Row 0 \SetRowColor{LightBackground} // & Insert single-line comment \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{example:} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} `//This is a single line comment` \{\{bb=1\}\} & \{\{bb=1\}\} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} /* & Insert multiple-line comment \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{example:} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{`/*This is`} \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{3.833cm}}{`a multiple`} \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{3.833cm}}{`line comment*/`} \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.16722 cm} x{2.26578 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Conditional Statements}} \tn % Row 0 \SetRowColor{LightBackground} `if` & used to specify a block of code to be executed, if a specified condition is true \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} `else` & used to specify a block of code to be executed, if the same condition is false \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} `else if` \{\{nobreak\}\} & used to to specify a new condition to test, if the first condition is false \tn % Row Count 10 (+ 3) % Row 3 \SetRowColor{white} `switch` & Used instead of writing many `if...else` statements \tn % Row Count 12 (+ 2) % Row 4 \SetRowColor{LightBackground} `break` & Used to stop the execution of more code and case testing inside the block \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.6866 cm} x{2.7464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Looping}} \tn % Row 0 \SetRowColor{LightBackground} `while` & Loops through a block of code as long as a specified condition is true \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \seqsplit{`do/while`} & This loop will execute the code block once, before checking if the condition is true, then it will repeat the loop as long as the condition is true \tn % Row Count 8 (+ 5) % Row 2 \SetRowColor{LightBackground} `for` & Loops through a block of code for a specified amount of repetitions \tn % Row Count 11 (+ 3) % Row 3 \SetRowColor{white} \seqsplit{`continue`} & Breaks one iteration (in the loop), if a specified condition occurs, and continues with the next iteration in the loop \tn % Row Count 15 (+ 4) % Row 4 \SetRowColor{LightBackground} `break` & Skips rest of loop contents and exits loop \tn % Row Count 17 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.71091 cm} p{0.55293 cm} p{0.68458 cm} p{0.68458 cm} } \SetRowColor{DarkBackground} \mymulticolumn{4}{x{3.833cm}}{\bf\textcolor{white}{Keywords}} \tn % Row 0 \SetRowColor{LightBackground} `auto` & \seqsplit{`double`} & `int` & `struct` \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `break` & `else` & `long` & `switch` \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `case` & `enum` & \seqsplit{`register`} & `typedef` \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `char` & \seqsplit{`extern`} & `return` & `union` \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `const` & `float` & `short` & \seqsplit{`unsigned`} \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} \seqsplit{`continue`} & `for` & `signed` & `void` \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} `default` & `goto` & `sizeof` & \seqsplit{`volatile`} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} `do` & `if` & `static` & `while` \tn % Row Count 8 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}----} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.51495 cm} x{2.91805 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Control characters (Escape sequences)}} \tn % Row 0 \SetRowColor{LightBackground} `\textbackslash{}a` & Alert (bell) character \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `\textbackslash{}b` & Backspace \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `\textbackslash{}f` & Formfeed \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} `\textbackslash{}n` & New line \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} `\textbackslash{}r` & Carriage return \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} `\textbackslash{}t` & Horizontal tab \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} `\textbackslash{}v` & Vertical tab \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \textbackslash{}\textbackslash{} & Backslash \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} `\textbackslash{}?` & Question mark \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} `\textbackslash{}'` & Single quote \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} `\textbackslash{}"` & Double quote \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} `\textbackslash{}0` & null \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} `\textbackslash{}nnn` & Any octal ANSI character code \tn % Row Count 13 (+ 1) % Row 13 \SetRowColor{white} `\textbackslash{}xhh` & Any hexadecimal ANSI character code \tn % Row Count 15 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{p{0.57627 cm} p{0.66726 cm} x{1.78947 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{Arithmetic Operators}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Operator}} & {\bf{Name}} & {\bf{Description}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} `+` & \seqsplit{Addition} & Adds together two values \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} `-` & \seqsplit{Subtraction} & Subtracts one value from another \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} `*` & \seqsplit{Multiplication} & Multiplies two values \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} `/` & \seqsplit{Division} & Divides one value by another \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} `\%` & Modulus & Returns the division remainder \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} `++` & \seqsplit{Increment} & Increases the value of a variable by 1 \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} `-{}-` & \seqsplit{Decrement} & Decreases the value of a variable by 1 \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{3}{x{3.833cm}}{`compute`, `calculate`, or `add` statments can also be used} \tn % Row Count 18 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.30454 cm} x{2.12846 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{3.833cm}}{\bf\textcolor{white}{Format Specifiers}} \tn % Row 0 \SetRowColor{LightBackground} `\%a` & Signed hexadecimal float \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} `\%c` & A character \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `\%d` or `\%i` \{\{nobreak\}\} & Signed decimal integer \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} `\%6d` & Print as a decimal integer, at least 6 characters wide \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} `\%e` & Signed decimal with scientific notation \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} `\%f` & Signed decimal float \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} `\%6f` & Print as floating point, at least 6 characters wide \tn % Row Count 13 (+ 3) % Row 7 \SetRowColor{white} `\%.2f ` & Print as floating point, 2 characters after decimal point \tn % Row Count 16 (+ 3) % Row 8 \SetRowColor{LightBackground} `\%6.2f` & Print as floating point, at least 6 wide and 2 after decimal point \tn % Row Count 19 (+ 3) % Row 9 \SetRowColor{white} `\%g` & Shortest representation of `\%f` or `\%e` \tn % Row Count 21 (+ 2) % Row 10 \SetRowColor{LightBackground} `\%o` & Unsigned octal integer \tn % Row Count 22 (+ 1) % Row 11 \SetRowColor{white} `\%s` & Character string \tn % Row Count 23 (+ 1) % Row 12 \SetRowColor{LightBackground} `\%u` & Unsigned decimal integer \tn % Row Count 24 (+ 1) % Row 13 \SetRowColor{white} `\%x` & Unsigned hexadecimal integer \tn % Row Count 26 (+ 2) % Row 14 \SetRowColor{LightBackground} `\%p` & Display a pointer \tn % Row Count 27 (+ 1) % Row 15 \SetRowColor{white} `\%\%` & Print a \% \tn % Row Count 28 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{3.833cm}{x{1.03122 cm} x{1.00089 cm} x{1.00089 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{Primitive Variable Types}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{3}{x{3.833cm}}{{\emph{applicable but not limited to most ARM, AVR, x86 \& x64 installations}} \{\{ac\}\}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{3}{x{3.833cm}}{`{[}class{]} {[}qualifier{]} {[}unsigned{]} type/void name;` \{\{ac\}\}} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{3}{x{3.833cm}}{{\emph{by ascending arithmetic conversion}} \{\{ac\}\} \{\{bt=1\}\}} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{3}{x{3.833cm}}{{\bf{Integers}}} \tn % Row Count 7 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{Type}} & {\bf{Bytes}} & {\bf{Value Range}} \tn % Row Count 9 (+ 2) % Row 5 \SetRowColor{white} `char` & 1 & `unsigned` or `signed` \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} `unsigned char` & 1 & 0 to 255 \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} `signed char` & 1 & -128 to 127 \tn % Row Count 14 (+ 1) % Row 8 \SetRowColor{LightBackground} `int` & 2 / 4 & `unsigned` or `signed` \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} `unsigned int` & 2 / 4 & 0 to 65,535 {\bf{or}} 2\textasciicircum{}31\textasciicircum{}-1 \tn % Row Count 18 (+ 2) % Row 10 \SetRowColor{LightBackground} `signed int` & 2 / 4 & -32,768 to 32,767 {\bf{or}} -2\textasciicircum{}31\textasciicircum{} to 2\textasciicircum{}32\textasciicircum{}-1 \tn % Row Count 22 (+ 4) % Row 11 \SetRowColor{white} `short` & 2 & `unsigned` or `signed` \tn % Row Count 24 (+ 2) % Row 12 \SetRowColor{LightBackground} `unsigned short` & 2 & 0 to 65,535 \tn % Row Count 26 (+ 2) % Row 13 \SetRowColor{white} `signed short` & 2 & -32,768 to 32,767 \tn % Row Count 28 (+ 2) % Row 14 \SetRowColor{LightBackground} `long` & 4 / 8 & `unsigned` or `signed` \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.03122 cm} x{1.00089 cm} x{1.00089 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{Primitive Variable Types (cont)}} \tn % Row 15 \SetRowColor{LightBackground} `unsigned long` & 4 / 8 & 0 to 2\textasciicircum{}32\textasciicircum{}-1 {\bf{or}} 2\textasciicircum{}64\textasciicircum{}-1 \tn % Row Count 3 (+ 3) % Row 16 \SetRowColor{white} `signed long` & 4 / 8 & -2\textasciicircum{}31\textasciicircum{} to 2\textasciicircum{}31\textasciicircum{}-1 {\bf{or}} -2\textasciicircum{}63\textasciicircum{} to 2\textasciicircum{}63\textasciicircum{}-1 \tn % Row Count 7 (+ 4) % Row 17 \SetRowColor{LightBackground} `long long` & 8 & `unsigned` or `signed` \tn % Row Count 9 (+ 2) % Row 18 \SetRowColor{white} `unsigned long long` & 8 & 0 to 2\textasciicircum{}64\textasciicircum{}-1 \tn % Row Count 11 (+ 2) % Row 19 \SetRowColor{LightBackground} `signed long long` \{\{bb=1\}\} & 8 \{\{bb=1\}\} & -2\textasciicircum{}63\textasciicircum{}to 2\textasciicircum{}63\textasciicircum{}-1 \{\{bb=1\}\} \tn % Row Count 14 (+ 3) % Row 20 \SetRowColor{white} \mymulticolumn{3}{x{3.833cm}}{// `signed` is the default modifier of `int` and `char` data type (allows + or - value)} \tn % Row Count 16 (+ 2) % Row 21 \SetRowColor{LightBackground} \mymulticolumn{3}{x{3.833cm}}{// `unsigned` only stores positive values} \tn % Row Count 17 (+ 1) % Row 22 \SetRowColor{white} {\bf{Floats}} \{\{bt=1\}\} \{\{nobreak\}\} & \{\{bt=1\}\} & \{\{bt=1\}\} \tn % Row Count 20 (+ 3) % Row 23 \SetRowColor{LightBackground} {\bf{Type}} & {\bf{Bytes}} & {\bf{Value Range (Normalized)}} \tn % Row Count 23 (+ 3) % Row 24 \SetRowColor{white} `float` & 4 & ±1.2×10\textasciicircum{}-38\textasciicircum{} to ±3.4×10\textasciicircum{}38\textasciicircum{} \tn % Row Count 26 (+ 3) % Row 25 \SetRowColor{LightBackground} `double` & 8 / 4 & ±2.3×10\textasciicircum{}-308\textasciicircum{} to ±1.7×10\textasciicircum{}308\textasciicircum{} {\bf{or}} alias to `float` for AVR \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.03122 cm} x{1.00089 cm} x{1.00089 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{Primitive Variable Types (cont)}} \tn % Row 26 \SetRowColor{LightBackground} `long double` & ARM: 8, AVR: 4, x86: 10, x64:16 & \tn % Row Count 3 (+ 3) % Row 27 \SetRowColor{white} {\bf{Qualifiers}} \{\{bt=1\}\} \{\{nobreak\}\} & \{\{bt=1\}\} & \{\{bt=1\}\} \tn % Row Count 6 (+ 3) % Row 28 \SetRowColor{LightBackground} `const type` & Flags variable as read-only (compiler can optimise) & \tn % Row Count 10 (+ 4) % Row 29 \SetRowColor{white} `volatile type` & Flags variable as \seqsplit{unpredictable} (compiler cannot optimise) & \tn % Row Count 15 (+ 5) % Row 30 \SetRowColor{LightBackground} {\bf{Storage Classes}} \{\{bt=1\}\} \{\{nobreak\}\} & \{\{bt=1\}\} & \{\{bt=1\}\} \tn % Row Count 19 (+ 4) % Row 31 \SetRowColor{white} `register` & Quick access required. May be stored in RAM {\bf{or}} a register. Maximum size is register size. & \tn % Row Count 27 (+ 8) % Row 32 \SetRowColor{LightBackground} `static` & Retained when out of scope. `static` global variables are confined to the scope of the compiled object file they were declared in. & \tn % Row Count 37 (+ 10) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{3.833cm}{x{1.03122 cm} x{1.00089 cm} x{1.00089 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{3.833cm}}{\bf\textcolor{white}{Primitive Variable Types (cont)}} \tn % Row 33 \SetRowColor{LightBackground} `extern` & Variable is declared by another file & \tn % Row Count 3 (+ 3) % Row 34 \SetRowColor{white} {\bf{Typecasting}} \{\{bt=1\}\} \{\{nobreak\}\} & \{\{bt=1\}\} & \{\{bt=1\}\} \tn % Row Count 6 (+ 3) % Row 35 \SetRowColor{LightBackground} `(type)a` & Returns `a` as data `type` & \tn % Row Count 8 (+ 2) % Row 36 \SetRowColor{white} \mymulticolumn{3}{x{3.833cm}}{`char x = 1, y = 2; float z = (float) x / y;` \{\{ac\}\}} \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \SetRowColor{LightBackground} \mymulticolumn{3}{x{3.833cm}}{Some types (denoted with {\bf{or}}) are architecture dependant. \newline \newline There is no primitive boolean type, only zero (false, `0`) and non-zero (true, usually `1`). \{\{ac\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}