\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{Alberto (aromano)} \pdfinfo{ /Title (c-language.pdf) /Creator (Cheatography) /Author (Alberto (aromano)) /Subject (C Language 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}{2A87A3} \definecolor{LightBackground}{HTML}{F1F7F9} \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 Language Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Alberto (aromano)} via \textcolor{DarkBackground}{\uline{cheatography.com/183740/cs/38265/}}} \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}Alberto (aromano) \\ \uline{cheatography.com/aromano} \\ \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 25th April, 2023.\\ 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*}{2} \begin{tabularx}{8.4cm}{x{4.104 cm} x{1.824 cm} x{1.672 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Formato dati}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Data Type}} & {\bf{Printf}} & {\bf{Scanf}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} int & \%d & \%d \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} unsigned int & \%u & \%u \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} long int & \%ld & \%ld \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} unsigned long int & \%lu & \%lu \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} long long int & \%lld & \%lld \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} unsigned long long int & \%llu & \%llu \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} double & \%f & \%lf \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} float & \%f & \%f \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} hex integer & \%x & \%x \tn % Row Count 12 (+ 1) % Row 10 \SetRowColor{LightBackground} decimal exponent & \%e & \%e \tn % Row Count 13 (+ 1) % Row 11 \SetRowColor{white} char & \%c & \%c \tn % Row Count 14 (+ 1) % Row 12 \SetRowColor{LightBackground} unsigned char & \%c & \%c \tn % Row Count 15 (+ 1) % Row 13 \SetRowColor{white} string & \%s & \%s \tn % Row Count 16 (+ 1) % Row 14 \SetRowColor{LightBackground} \%pointer & \%p & \%p \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.6 cm} x{6.4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Sequenze di Escape}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Escape}} & {\bf{Azione}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \textbackslash{}n & Va a capo. \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \textbackslash{}t & Va alla tabulazione successiva. \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \textbackslash{}a & Produce suono o allarme visibile senza cambiare posizione del cursore. \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} \textbackslash{}\textbackslash{} & Scrive un backlash. \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \textbackslash{}" & Scrive le doppie virgolette. \tn % Row Count 9 (+ 1) % Row 6 \SetRowColor{LightBackground} \textbackslash{}? & Scrive il punto interrogativo. \tn % Row Count 10 (+ 1) % Row 7 \SetRowColor{white} \textbackslash{}' & Scrive un'apostrofo. \tn % Row Count 11 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4.32 cm} x{3.68 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Operatori Logici}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Operatore}} & {\bf{Simbolo}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} AND & \&\& \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} OR & || \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} NOT & ! \tn % Row Count 4 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{NOT è unario \newline EX: !a} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Definire Array e Matrici}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`int i{[}10{]};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce un array di interi di grandezza 10.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`int i{[}10{]} = \{0\};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce un array di interi di grandezza 10 e inizializza tutte le celle a 0.} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`char i{[}10{]};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce un array di char di grandezza 10: può contenere al massimo 9 caratteri.} \tn % Row Count 8 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`char i{[}{]} = "ciao";`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce un array di char di grandezza 5: 4 lettere e il terminatore di stringa '\textbackslash{}0'.} \tn % Row Count 11 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`char i{[}{]} = \{'c', 'i', 'a', 'o', '\textbackslash{}0'\};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Equivalente al precedente.} \tn % Row Count 13 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`int i{[}2{]}{[}3{]};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce una matrice 2*3.} \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`int i{[}2{]}{[}3{]} = \{\{1, 2, 3\},\{\{nl\}\} \{4, 5, 6\},\};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce una matrice 2*3 e inizializza ogni riga con valori da 1 a 6.} \tn % Row Count 19 (+ 4) % Row 7 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{`int i{[}{\emph{variabile}}{]};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce un array delle dimensioni conservate in {\emph{variabile}}. Caso di VLA.} \tn % Row Count 22 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`int i{[}{\emph{SIZE}}{]};`} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce un array di dimensioni pari alla costante simbolica {\emph{SIZE}}.} \tn % Row Count 25 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Un vettore preceduto da {\bf{const}} non può essere modificato nel suo contenuto.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Definire una Struttura}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{struct dati \newline \{ \newline int sensore; \newline char stringa{[}10{]}; \newline float media; \newline \};} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Una struttura include variabili e array anche di tipi diversi. \newline Se la struttura è usata da più funzioni, porre la struttura fuori dal corpo della main.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Puntatori}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{int *pointer;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Dichiara un puntatore a un intero.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{char *pointer;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Dichiara un puntatore a un char.} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{int *const pointer;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Dichiara un puntatore costante. Il contenuto a cui punta può essere modificato.} \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{int const* pointer;` || `const int* pointer;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Dichiara un puntatore variabile. Il contenuto a cui punta non può essere modificato.} \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{const int* const pointer;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Dichiara un puntatore costante a variabile costante. Il contenuto a cui punta non può essere modificato.} \tn % Row Count 14 (+ 4) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{pointer = \&variabile;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Assegna al puntatore l'indirizzo della variabile.} \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Il puntatore è un valore che indica l'indirizzo del dato a cui punta, non il suo contenuto.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.8 cm} x{5.2 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Passare Array e Matrici alle Funzioni}} \tn % Row 0 \SetRowColor{LightBackground} Array & void nomeFunzione (int {[}{]}); \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Array & void nomeFunzione (int array{[}{]}); \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Matrice a 2 dimensioni & void nomeFunzione (int matrice{[}{]}{[}DIM2{]}); \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Matrice a 3 dimensioni & void nomeFunzione (int matrice{[}{]}{[}DIM2{]}{[}DIM3{]}); \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} VLA & void nomeFunzione (int array{[}*{]}, int {\emph{size}}); \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} VLA a 2 dimensioni & void nomeFunzione (int array{[}{]}{[}*{]}, int {\emph{size}}, int {\emph{size2}}); \tn % Row Count 13 (+ 3) % Row 6 \SetRowColor{LightBackground} VLA a 3 dimensioni & void nomeFunzione (int array{[}{]}{[}*{]}{[}*{]}, int {\emph{size}}, int {\emph{size2}}, int {\emph{size3}}); \tn % Row Count 16 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{1 e 2 sono equivalenti. \newline Non è necessario passare il nome di un array monodimensionale. \newline Non è necessario passare il nome delle dimensioni, basta specificare il tipo.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{File}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{FILE *filepointer;} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Definisce il puntatore al file.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{filepointer = fopen("file.txt", "w");} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Inizializza il puntatore per aprire il file e ne definisce la modalità di apertura.} \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{fclose(filepointer);} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Chiude lo stream del file.} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{fprintf(filepointer, "testo", variabili…);} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Stampa nel file il testo e il contenuto delle variabili.} \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{fscanf(filepointer, "\%formato", \&variabili…);} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Riceve dal file l'input desiderato.} \tn % Row Count 12 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{fwrite(origine, dimensioneInByte, numElementi, filepointer);} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Scrive sul file le informazioni presenti nell'origine.} \tn % Row Count 16 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{fread(destinazione, dimensioneInByte, numElementi, filepointer);} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Legge e scrive in destinazione le informazioni presenti nel file.} \tn % Row Count 20 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{fwrite e fread restituiscono il valore intero di quanti elementi sono stati scritti/letti.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.36 cm} x{6.64 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Tipi di Variabili}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Type}} & {\bf{Scope}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{Extern} & Prefisso che indica una variabile dichiarata in un modulo (es .h) esterno al modulo chela usa. \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \seqsplit{Global} & Dichiarata esternamente alle funzioni e visibile in ogni funzione \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{Static} & Come locale ma non è distrutta quando la funzione cede il controllo al chiamante \tn % Row Count 10 (+ 3) % Row 4 \SetRowColor{LightBackground} Local & Ha una visibilità limitata ad una funzione o una iterazione (for). \tn % Row Count 13 (+ 3) % Row 5 \SetRowColor{white} SI & `\#include "myfile.h"\{\{nl\}\}extern int var;\{\{nl\}\}int main(void)\{\{nl\}\}\{\{\{nl\}\}var = 10; return 0;\{\{nl\}\}\}` \tn % Row Count 17 (+ 4) % Row 6 \SetRowColor{LightBackground} NO & `extern int var; \{\{nl\}\}int main(void) \{\{nl\}\}\{ \{\{nl\}\}var = 10; \{\{nl\}\}return 0; \{\{nl\}\}\}` \tn % Row Count 20 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Con extern dichiarare dove si trova la variabile. \newline EX: myfile.h} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.76 cm} x{6.24 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Incremento e Decremento}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Formato}} & {\bf{Azione}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} a++ & Rende disponibile la variabile, poi la incrementa \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} ++a & Incrementa la variabile, poi la rende disponibile \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} a-{}- & Rende disponibile la variabile, poi la decrementa \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} -{}-a & Decrementa la variabile, poi la rende disponibile \tn % Row Count 10 (+ 2) % Row 5 \SetRowColor{white} a += & Somma ad a la parte destra, poi assegna ad a \tn % Row Count 12 (+ 2) % Row 6 \SetRowColor{LightBackground} a -= & Sottrae ad a la parte destra, poi assegna ad a \tn % Row Count 14 (+ 2) % Row 7 \SetRowColor{white} a *= & Moltiplica a per a la parte destra, poi assegna ad a \tn % Row Count 16 (+ 2) % Row 8 \SetRowColor{LightBackground} a /= & Divide a per a la parte destra, poi assegna ad a \tn % Row Count 18 (+ 2) % Row 9 \SetRowColor{white} a \%= & Trova il resto tra a e la parte destra, poi assegna ad a \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.24 cm} x{5.76 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Manipolazione su bit}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Simbolo}} & {\bf{Azione}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} x\textgreater{}\textgreater{}y & x scorre a destra di y bit \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} x\textless{}\textless{}y & x scorre a sinistra di y bit \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} x\&y & AND bit a bit tra x e y \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} x|y & OR bit a bit tra x e y \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} x\textasciicircum{}y & XOR bit a bit tra x e y \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \textasciitilde{}x & Complemento dei bit di x \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{\textasciitilde{} è un operatore unario.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Operatore Ternario}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{(condizione) ? Espressione 1 : Espressione 2 ;} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Se la condizione è {\bf{vera}} verrà eseguita Espressione 1; \newline Se la condizione è {\bf{falsa}} verrà eseguita Espressione 2.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Generare Numeri Random}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Genera numeri casuali} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}i = rand();} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Genera numeri casuali in un intervallo preciso} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}i = minimo + rand() \% (massimo - minimo + 1);} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Scegliere un seme sempre diverso} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}srand(time(NULL));} \tn % Row Count 6 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{Per utilizzare rand() e srand() è necessario includere \textless{}stdlib.h\textgreater{}. \newline Per utilizzare time(NULL) è necessario includere \textless{}time.h\textgreater{}.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{p{0.76 cm} x{2.964 cm} x{3.876 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Modalità Apertura File}} \tn % Row 0 \SetRowColor{LightBackground} r & Lettura & Se il file non esiste, fopen() restituisce NULL. \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} r+ & Lettura e Scrittura & Se il file non esiste, fopen() restituisce NULL. \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} w & Scrittura & Se il file non esiste viene creato, se esiste viene sovrascritto. \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} w+ & Lettura e Scrittura & Se il file non esiste viene creato, se esiste viene sovrascritto. \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} a & Append & Se il file non esiste viene creato. \tn % Row Count 16 (+ 2) % Row 5 \SetRowColor{white} a+ & Lettura e Append & Se il file non esiste viene creato. \tn % Row Count 18 (+ 2) % Row 6 \SetRowColor{LightBackground} rb & Lettura binaria & Se il file non esiste, fopen() restituisce NULL. \tn % Row Count 21 (+ 3) % Row 7 \SetRowColor{white} rb+ & Lettura e Scrittura binaria & Se il file non esiste, fopen() restituisce NULL. \tn % Row Count 24 (+ 3) % Row 8 \SetRowColor{LightBackground} wb & Scrittura binaria & Se il file non esiste viene creato, se esiste viene sovrascritto. \tn % Row Count 28 (+ 4) % Row 9 \SetRowColor{white} wb+ & Lettura e Scrittura binaria & Se il file non esiste viene creato, se esiste viene sovrascritto. \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{p{0.76 cm} x{2.964 cm} x{3.876 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Modalità Apertura File (cont)}} \tn % Row 10 \SetRowColor{LightBackground} ab & Append binario & Se il file non esiste viene creato. \tn % Row Count 2 (+ 2) % Row 11 \SetRowColor{white} ab+ & Lettura e Append & Se il file non esiste viene creato. \tn % Row Count 4 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Operazioni sui Puntatori}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Operazione}} & {\bf{Azione}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} pointer + i & Sposta il puntatore di i posizioni in avanti. \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} pointer - i & Sposta il puntatore di i posizioni indietro. \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} pointer1 - pointer2 & Quanti dati del tipo puntato possono inserire tra la posizione di pointer1 e pointer2. \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} pointer++ & Sposta di una posizione il puntatore. \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Spostare significa aumentare o diminuire di tot. byte (in base alla dimensione del tipo puntato) l'indirizzo del puntatore. \newline 'i' è un valore intero.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.116 cm} x{3.116 cm} x{1.368 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Precedenze}} \tn % Row 0 \SetRowColor{LightBackground} Operatore & Descrizione & \seqsplit{Associatività} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} ()\{\{nl\}\} {[}{]}\{\{nl\}\}++ -{}- & \seqsplit{Parentesi/Chiamata} a funzione\{\{nl\}\}Parentesi/Indice Array\{\{nl\}\}Postincremento/Postdecremento & \seqsplit{Sinistra} - Destra \tn % Row Count 8 (+ 6) % Row 2 \SetRowColor{LightBackground} ++ -{}-\{\{nl\}\} (type)\{\{nl\}\} *\{\{nl\}\}\&\{\{nl\}\} sizeof & Preincrementi/Predecrementi\{\{nl\}\}Cast\{\{nl\}\}Indirezione puntatore/Deferenziazione\{\{nl\}\}Indirizzo puntatore\{\{nl\}\}Operatore sizeof & Destra - \seqsplit{Sinistra} \tn % Row Count 16 (+ 8) % Row 3 \SetRowColor{white} * / \% & Moltiplicazione, Divisione e Modulo & \seqsplit{Sinistra} - Destra \tn % Row Count 19 (+ 3) % Row 4 \SetRowColor{LightBackground} + - & Somma e sottrazione & \seqsplit{Sinistra} - Destra \tn % Row Count 22 (+ 3) % Row 5 \SetRowColor{white} \textless{}\textless{} \textgreater{}\textgreater{} & Shift bit a bit & \seqsplit{Sinistra} - Destra \tn % Row Count 25 (+ 3) % Row 6 \SetRowColor{LightBackground} \textless{} \textless{}= \textgreater{} \textgreater{}= & Confronto relazioni & \seqsplit{Sinistra} - Destra \tn % Row Count 28 (+ 3) % Row 7 \SetRowColor{white} == != & Confronto uguaglianza & \seqsplit{Sinistra} - Destra \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{3.116 cm} x{3.116 cm} x{1.368 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{8.4cm}}{\bf\textcolor{white}{Precedenze (cont)}} \tn % Row 8 \SetRowColor{LightBackground} \&\& & AND Logico & \seqsplit{Sinistra} - Destra \tn % Row Count 3 (+ 3) % Row 9 \SetRowColor{white} || & OR Logico & \seqsplit{Sinistra} - Destra \tn % Row Count 6 (+ 3) % Row 10 \SetRowColor{LightBackground} ? : & Operatore ternario & Destra - \seqsplit{Sinistra} \tn % Row Count 9 (+ 3) % Row 11 \SetRowColor{white} =\{\{nl\}\} += -=\{\{nl\}\} *= /= \%= & Assegnazione\{\{nl\}\}Operazione e assegnazione & Destra - \seqsplit{Sinistra} \tn % Row Count 12 (+ 3) % Row 12 \SetRowColor{LightBackground} , & Operatore virgola & \seqsplit{Sinistra} - Destra \tn % Row Count 15 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Pulire Schermo}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{\#include \textless{}windows.h\textgreater{} || \{\{nl\}\}\#include \textless{}process.h\textgreater{} || \{\{nl\}\}\#include \textless{}stdlib.h\textgreater{}} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Inserire la libreria necessaria al funzionamento.} \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{system("pause");} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Chiede all'utente di premere un tasto per continuare.} \tn % Row Count 7 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{system("cls"); //windows` || \{\{nl\}\}`system("clear"); //linux} \tn \mymulticolumn{1}{x{8.4cm}}{\hspace*{6 px}\rule{2px}{6px}\hspace*{6 px}Pulisce lo schermo dal testo precedente.} \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}