\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{solsolsol} \pdfinfo{ /Title (c.pdf) /Creator (Cheatography) /Author (solsolsol) /Subject (C 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}{916C20} \definecolor{LightBackground}{HTML}{F8F5F1} \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 Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{solsolsol} via \textcolor{DarkBackground}{\uline{cheatography.com/32070/cs/9956/}}} \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}solsolsol \\ \uline{cheatography.com/solsolsol} \\ \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 19th January, 2017.\\ 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*}{3} \begin{tabularx}{5.377cm}{x{1.78503 cm} x{1.32733 cm} x{1.46464 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Display format}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{type}} & \{\{ac\}\}{\bf{code}} & \{\{ac\}\}{\bf{print}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \{\{bt\}\}{\bf{char}} c='a' & \{\{ac\}\}\{\{bt\}\}\%c\{\{nl\}\}\%d & \{\{ac\}\}\{\{bt\}\}a\{\{nl\}\}97 \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{char}} s{[}{]}="Str" & \{\{ac\}\}\%s & \{\{ac\}\}Str \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \{\{bt\}\}{\bf{int}} n=5 & \{\{ac\}\}\{\{bt\}\}\%d & \{\{ac\}\}\{\{bt\}\}5 \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\emph{hexa}} & \{\{ac\}\}\%x & \{\{ac\}\}fb \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} {\emph{octal}} & \{\{ac\}\}\%o & \{\{ac\}\}... \tn % Row Count 10 (+ 1) % Row 6 \SetRowColor{LightBackground} \{\{bt\}\}{\bf{float}} n=2.3521 & \{\{bt\}\}\{\{ac\}\}\%f & \{\{ar\}\}\{\{bt\}\}2.352100 \tn % Row Count 12 (+ 2) % Row 7 \SetRowColor{white} \%{[}a{]}.{[}b{]}f/{\bf{e}}(xpo) & \{\{ac\}\}\%6.2f & \{\{ar\}\}\_\_\_2.35 \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} a: espce reservé & \{\{ac\}\}\%8.2f & \{\{ar\}\}\_\_\_\_\_2.35 \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} b: decimales & \{\{ac\}\}\%.3f & \{\{ar\}\}2.3521 \tn % Row Count 17 (+ 1) % Row 10 \SetRowColor{LightBackground} \{\{bt\}\}float n; \{\{nl\}\}n=pow(9,9); & \{\{bt\}\}\{\{ac\}\}\{\{nl\}\}\%f & \{\{bt\}\}\{\{ac\}\}\{\{nl\}\}283242953.000 \tn % Row Count 20 (+ 3) % Row 11 \SetRowColor{white} & \{\{ac\}\}{\bf{\%e}} & \{\{ac\}\}2.824295{\bf{e}}+011 \tn % Row Count 22 (+ 2) % Row 12 \SetRowColor{LightBackground} \{\{bt\}\}(int) {\bf{*}}ptr;\{\{nl\}\}ptr={\bf{\&}}n; & \{\{bt\}\}\{\{ac\}\}\{\{nl\}\}"{\bf{\%p}}",ptr & \{\{bt\}\}\{\{ac\}\}\{\{nl\}\}adr {\bf{n}} (hex) \tn % Row Count 25 (+ 3) % Row 13 \SetRowColor{white} \{\{bt\}\}int j=007 & \{\{bt\}\}\{\{ac\}\}\%{\bf{02}}d & \{\{bt\}\}\{\{ac\}\}07 \tn % Row Count 27 (+ 2) % Row 14 \SetRowColor{LightBackground} force zero avt & \{\{ac\}\}\%{\bf{03}}d & \{\{ac\}\}007 \tn % Row Count 29 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{While Loop}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{while}} (i \textgreater{}= 0)} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{A while loop continues executing the while block as long as the condition in the while holds.} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{break;}}\{\{nl\}\} The break statement immediately exits the innermost loop in which it is found.} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{continue;}}\{\{nl\}\} The continue statement skips to the bottom of the innermost loop in which it is found and tests whether to repeat the loop again.} \tn % Row Count 9 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.93643 cm} x{2.04057 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Opérateur ternaire ?}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{sorte de if ... then ... else ...} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{`int i,k,j = 3;`} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} `i = ((j == 2) ? 1 : 3) ;` & i =1 \tn % Row Count 4 (+ 2) % Row 3 \SetRowColor{white} `k = ((i \textgreater{} j) ? i : j) ;` & k = 2 (i=1 et j=2) \tn % Row Count 6 (+ 2) % Row 4 \SetRowColor{LightBackground} `i = j == 2 ? 1 : 3 ;` & ) ( optionnels \tn % Row Count 7 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.94103 cm} x{3.03597 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{cool stuff}} \tn % Row 0 \SetRowColor{LightBackground} sizeof(type) & poids du type en bytes \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \seqsplit{sizeof(tableau)} & poids du tableau en arg \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{} \tn % Row Count 2 (+ 0) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Programmation modulaire:} \tn % Row Count 3 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{\#include "nom.h"}}\{\{nl\}\}fichier dans le rep du projet} \tn % Row Count 5 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{\#include \textless{}fichier.h\textgreater{}}}\{\{nl\}\}dans le rep "include" de l'IDE} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Allocation dynamique tab 2,3...d}} \tn % Row 0 \SetRowColor{LightBackground} int m{[}3{]}{[}5{]}; & declaration statique \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} int **matrice; & declaration dynamique \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{bt\}\}p{[}i{]} = *(p+i)} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Les ecritures suivantes sont {\bf{TOUTES}} pareil:} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} p{[}1{]}{[}2{]} + 3 & (*(p+1)) {[}2{]} + 3 \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} *(p{[}1{]} + 2)) + 3 & *(*(p + 1) + 2) + 3 \tn % Row Count 6 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.64772 cm} x{1.32733 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Tableaux}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Ensemble de variables du {\bf{même type}} stockées les unes après les autres en mémoire.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{Taille fixée avant la compilation.} \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Chaque case d'un tableau de type {\bf{int}} contient une variable de type {\bf{int}}.} \tn % Row Count 5 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{Cases numérotées via {\bf{indices}}. Start @ 0.} \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{int tab{[}3{]};\{\{nl\}\}tab{[}0{]} = 10;\{\{nl\}\}tab{[}1{]} = 2;\{\{nl\}\}tab{[}2{]} = 6;}}\{\{nl\}\} & {\bf{Adresse}}\{\{nl\}\}1600\{\{nl\}\}1601\{\{nl\}\}1602 & {\bf{Valeur}}\{\{nl\}\}10\{\{nl\}\}2\{\{nl\}\}6 \tn % Row Count 12 (+ 6) % Row 5 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{Un tab commence à l'indice {\bf{0}}. Ce tab a donc les indices 0,1 et 2. Pour un tab de {\bf{n}} cases, indice max = {\bf{n-1}}.} \tn % Row Count 15 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}La variable {\bf{tab}} est un pointeur sur la première case du tableau.} \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} {\bf{printf("\%d", tab)}}; & \{\{fa-long-arrow-right\}\} & 1600 \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}{\bf{Adresse}} de la première case (deci)} \tn % Row Count 20 (+ 1) % Row 9 \SetRowColor{white} {\bf{printf("\%d\textbackslash{}n",tab{[}0{]});}}\{\{nl\}\} & \{\{fa-long-arrow-right\}\} & 10 \tn % Row Count 23 (+ 3) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}{\bf{Valeur}} contenue dans la première case.} \tn % Row Count 24 (+ 1) % Row 11 \SetRowColor{white} {\bf{printf("\%d\textbackslash{}n",*tab)}};\{\{nl\}\} & \{\{fa-long-arrow-right\}\} & 10 \tn % Row Count 27 (+ 3) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}Comme {\bf{tab}} est un pointeur, le cast avec * devant le nom renvoie la valeur contenue dans la case qu'il pointe.} \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{1.60195 cm} x{1.64772 cm} x{1.32733 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Tableaux (cont)}} \tn % Row 13 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}{\bf{printf("\%d", tab{[}1{]})}} et {\bf{printf("\%d", *(tab + 1))}}\{\{nl\}\} Equivalents: Return val de la seconde case.} \tn % Row Count 3 (+ 3) % Row 14 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{\{\{ac\}\}{\bf{Initialisation:}}} \tn % Row Count 4 (+ 1) % Row 15 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{{\bf{int tab{[}2{]} = \{10,2,6\};}}\{\{nl\}\}Est équivalent a la première initialisation.} \tn % Row Count 6 (+ 2) % Row 16 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{{\bf{int tab{[}5{]} = \{10,2\};}}\{\{nl\}\}Initialise les cases non-attribuées a {\bf{0}}.\{\{nl\}\}(valeurs insérées: {\bf{10,2,0,0,0}}).} \tn % Row Count 9 (+ 3) % Row 17 \SetRowColor{LightBackground} {\bf{int tab{[}100{]} = \{0\};}}\{\{nl\}\} Les 100 cases à 0. & {\bf{int tab{[}100{]} = \{1\}}};\{\{nl\}\}1,0,0,... & \tn % Row Count 13 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Tableaux \& fonctions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{void affiche(int *tableau, int lenTab)\{ \newline int i; \newline for (i=0; i\textless{}lenTab; i++)\{ \newline printf("\%d\textbackslash{}n",tableau{[}i{]});\}\} \newline int main()\{ \newline int tab{[}4{]} = \{1,6,3,12\}; \newline affiche(tab, 4);...\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`La fonction prend en paramètre un pointeur sur {\bf{int}}(tableau) {\bf{ainsi que la taille du tableau}}.`{\bf{void affiche(int *tableau, int lenTab)}} \newline {\bf{void affiche(int tableau{[}{]}, int lenTab)}} \newline `Produisent le même résultat la seconde notation à l'avantage de rendre le code plus lisible en montrant'que cet argument est un tableau et non pas un simple pointeur. {\bf{pas nécessaire de préciser la taille du tableau entre {[}{]}.}}`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.64772 cm} p{0.77809 cm} x{2.15119 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Strings}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{char str{[}4{]};}} & {\bf{Adresse}} & {\bf{Valeur}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} {\bf{str{[}0{]}='S';}} & 18000 & {\bf{0x53}} ('S') \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{str{[}1{]}='O';}} & 18001 & {\bf{0x4F}} ('O') \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} {\bf{str{[}2{]}='L';}} & 18002 & {\bf{0x4C}} ('L') \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} {\emph{end char}} & 18003 & {\bf{0x00}} ('\textbackslash{}0') \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{\{\{bt\}\}{\bf{char str{[}{]}="SOL"}} produit le meme resultat.} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \{\{bt\}\}{\bf{Scanf}} de str: & \{\{bt\}\} & \{\{bt\}\}({\bf{\%s}} et pas de {\bf{\&}}) \tn % Row Count 13 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{int i; char prenom{[}100{]};\{\{nl\}\}scanf("{\bf{\%s}}", prenom);\{\{nl\}\}for(i=0; i\textless{}strlen(prenom); i++)\{\{nl\}\}~ printf("\%c",prenom{[}i{]});} \tn % Row Count 16 (+ 3) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\#\#\#\#\#\#{\bf{A COMPLETER AVEC FGETS}}\#\#\#\#\#\#} \tn % Row Count 17 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4577 cm} x{1.8308 cm} x{2.2885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Structures}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Type de variable personalisé composé de sous-variables (et tableaux).} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & \{\{bt\}\}\{\{ac\}\}{\bf{initialisation structure:}} & \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{{\bf{struct}} Personne \{} \tn % Row Count 6 (+ 1) % Row 3 \SetRowColor{white} & & char nom{[}100{]}, prenom{[}100{]}; \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} & & int age;{\bf{\};}} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} & \{\{ac\}\}{\bf{initialisation nouveau type:}} & \tn % Row Count 12 (+ 3) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}{\bf{struct}} Personne {\emph{vladimir}} ;} \tn % Row Count 13 (+ 1) % Row 7 \SetRowColor{white} & \{\{ac\}\}{\bf{alias de structure:}} & \tn % Row Count 15 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}{\bf{typedef struct}} Personne {\bf{Employe}};} \tn % Row Count 16 (+ 1) % Row 9 \SetRowColor{white} & \{\{ac\}\}{\bf{initialisation nouveau type via alias:}} & \tn % Row Count 19 (+ 3) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bb\}\}{\bf{Employe}} {\emph{vladimir}} ;} \tn % Row Count 20 (+ 1) % Row 11 \SetRowColor{white} & \{\{ac\}\}{\bf{init instance + variables d'instance}}: & \tn % Row Count 23 (+ 3) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Employe} \tn % Row Count 24 (+ 1) % Row 13 \SetRowColor{white} & & jo = \{"","",0\}, ({\bf{virgule}}) (initialistion ss valeur) \tn % Row Count 27 (+ 3) % Row 14 \SetRowColor{LightBackground} & & claudie = \{"Fokan", "Claudie", 16\}, ({\bf{virgule}}) \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{p{0.4577 cm} x{1.8308 cm} x{2.2885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{3}{x{5.377cm}}{\bf\textcolor{white}{Structures (cont)}} \tn % Row 15 \SetRowColor{LightBackground} & & george = \{"Berger", "George", 32\}, ({\bf{virgule}}) \tn % Row Count 3 (+ 3) % Row 16 \SetRowColor{white} & & a = \{"Plo","Ad",4\}; ({\bf{point virgule}}) \tn % Row Count 5 (+ 2) % Row 17 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{\{\{bt\}\}("\%s\textbackslash{}n\%s\textbackslash{}n\%d\textbackslash{}n", {\bf{a.nom}}, {\bf{a.prenom}}, {\bf{a.age}});} \tn % Row Count 7 (+ 2) % Row 18 \SetRowColor{white} & \{\{bt\}\}\{\{ac\}\}{\bf{Tableau d'instances}}: & \tn % Row Count 10 (+ 3) % Row 19 \SetRowColor{LightBackground} \mymulticolumn{3}{x{5.377cm}}{Employe cadres{[}1{]};} \tn % Row Count 11 (+ 1) % Row 20 \SetRowColor{white} & & cadres{[}0{]} = claudie; \tn % Row Count 12 (+ 1) % Row 21 \SetRowColor{LightBackground} & & cadres{[}1{]} = george; \tn % Row Count 13 (+ 1) % Row 22 \SetRowColor{white} \mymulticolumn{3}{x{5.377cm}}{\{\{bt\}\}for(int i=0; i\textless{}2; i++)} \tn % Row Count 14 (+ 1) % Row 23 \SetRowColor{LightBackground} & & \{\{bb\}\}pf("cadre \%d: \%s\textbackslash{}n",i+1, cadres{[}i{]}.prenom); \tn % Row Count 17 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}---} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Structures \& Pointeurs}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/solsolsol_1484524159_explicationPointeurs_Struc.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{enum}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{p{5.377cm}}{\vspace{1px}\centerline{\includegraphics[width=5.1cm]{/web/www.cheatography.com/public/uploads/solsolsol_1484525464_enum.png}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{4.4793 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{scanf() : Syntax}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{scanf("command string", {\bf{\&}}var1,{\bf{\&}}var2,...);} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\{\{bt\}\}{\bf{int}} day, month, year;\{\{nl\}\}scanf("\%d/\%d/\%d", {\bf{\&}}day,{\bf{\&}}month,{\bf{\&}}year);} \tn % Row Count 3 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{=} \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{scanf( " \%d", {\bf{\&}}day);\{\{nl\}\}scanf( " \%d", {\bf{\&}}month);\{\{nl\}\}scanf( " \%d", {\bf{\&}}year);\{\{nl\}\}{\bf{ADD A SPACE IN FRON OF THE \%}}} \tn % Row Count 7 (+ 3) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{bt\}\}When prompted to enter values:} \tn % Row Count 8 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{{[}enter{]}{[}tab{]}}} and {\bf{{[}space{]}}} can be used to separat4e the entered values.} \tn % Row Count 10 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{To finish use {\bf{{[}enter{]}}}} \tn % Row Count 11 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{char a, b;\{\{nl\}\}scanf("\%c \%c", \&a, \&b);} \tn % Row Count 12 (+ 1) % Row 8 \SetRowColor{LightBackground} {[}a{]}{\bf{{[}enter{]}}}{[}b{]}{\bf{{[}enter{]}}} & OK \tn % Row Count 13 (+ 1) % Row 9 \SetRowColor{white} {[}a{]}{\bf{{[}space{]}}}{[}b{]}{\bf{{[}enter{]}}} & OK \tn % Row Count 14 (+ 1) % Row 10 \SetRowColor{LightBackground} {[}a{]}{[}b{]}{\bf{{[}enter{]}}} & OK \tn % Row Count 15 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\emph{When requested all char programmed need to be filed in in the prompt to go further.}}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Pointeurs}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quand on déclare une variable, une case mémoire est attribuée à cette variable qui sans être initialisée vaut une valeur aléatoire.} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} int {\bf{v1}}; & C000 {[}4CF1{]} = {\bf{v1}} \tn % Row Count 4 (+ 1) % Row 2 \SetRowColor{LightBackground} {\bf{v1}} = 10; & C000 {[}000A{]} = {\bf{v1}} \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\{\{bb\}\}Après initialisation la case mémoire est remplacée par la valeur d'initialisation.} \tn % Row Count 7 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quand on déclare un *pointeur 2 cases mémoire sont attribuées. Une pour la variable {\bf{{\emph{pointeur}}}} et une autre pour l'entité {\bf{*pointeur}}. \{\{nl\}\}Comme pour une variable classique déclarée sans être initialisée {\bf{{\emph{pointeur}}}} vaut une valeur alléatoire.} \tn % Row Count 13 (+ 6) % Row 5 \SetRowColor{white} int *pointeur; & BFFC {[}0020{]} = {\bf{{\emph{pointeur}}}} \tn % Row Count 15 (+ 2) % Row 6 \SetRowColor{LightBackground} & 0020 {[}0000{]} = {\bf{*pointeur}} \tn % Row Count 17 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Un *pointeur a besoin de deux cases mémoires avant initialisation. Une pour stocker la variable qui le référence et une autre qui stock le pointeur en lui même. L'adresse ou se trouve le pointeur en lui même est la valeur aléatoirement attribuée à la variable qui le référence.} \tn % Row Count 23 (+ 6) % Row 8 \SetRowColor{LightBackground} & C000 {[}000A{]} = {\bf{v1}} \tn % Row Count 24 (+ 1) % Row 9 \SetRowColor{white} pointeur = \&{\bf{v1}}; & C000 {[}000A{]} = {\bf{*pointeur}} \tn % Row Count 26 (+ 2) % Row 10 \SetRowColor{LightBackground} & BFFC {[}0020{]} = {\bf{{\emph{pointeur}}}} \tn % Row Count 28 (+ 2) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Une fois la variable qui référence le pointeur ({\bf{{\emph{pointeur}}}}) initialisée sur une variable({\bf{va1}}, le pointeur en lui même ({\bf{*pointeur}}) "fusionne" avec cette variable. Toute modification de la valeur de {\bf{*pointeur}} modifie la valeur de {\bf{v1}} et vice versa.} \tn % Row Count 34 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.09034 cm} x{2.88666 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Pointeurs (cont)}} \tn % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{printf("adr:\%p,val:\%p",\&{\bf{*pointeur,*pointeur}});\{\{nl\}\}=\textgreater{}adr:C000,val:000A} \tn % Row Count 2 (+ 2) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{printf("adr:\%p,val:\%p",\&{\bf{v1,v1}});\{\{nl\}\}=\textgreater{}adr:C000,val:000A} \tn % Row Count 4 (+ 2) % Row 14 \SetRowColor{LightBackground} {\bf{*pointeur}} = 20; & =\textgreater{} {\bf{v1}} = 20 \tn % Row Count 6 (+ 2) % Row 15 \SetRowColor{white} {\bf{v1}} = 1020; & =\textgreater{} {\bf{*pointeur}} = 1020 \tn % Row Count 8 (+ 2) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{ac\}\} {\bf{{\emph{pointeur}}}} pointe sur {\bf{v1}} =\textgreater{} {\bf{*pointeur}} = v1} \tn % Row Count 10 (+ 2) % Row 17 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\{\{bt\}\}Une variable stock un nombre} \tn % Row Count 11 (+ 1) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Un {\bf{{\emph{pointeur}}}} stock l'adresse d'une variable} \tn % Row Count 12 (+ 1) % Row 19 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Un {\bf{*pointeur}} est l'outil qui permet ça} \tn % Row Count 13 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Pointeurs exemple}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{int a, b, c, *ptr;} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} ptr = \&a; & //ptr pointe sur a \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} *ptr = 4; & //a = 4 \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} b = a + 5; & //b = 9 \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} ptr = \&b; & //ptr pointe sur b \tn % Row Count 5 (+ 1) % Row 5 \SetRowColor{white} c = *ptr; & //c = 9 \tn % Row Count 6 (+ 1) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{\{\{bb\}\}\{\{ac\}\}{\bf{ a = 4 ; b = 9 ; c = 9}}} \tn % Row Count 7 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{char a, b, c, *ptr;} \tn % Row Count 8 (+ 1) % Row 8 \SetRowColor{LightBackground} a = b = 3; & //a = 3 b = 3 \tn % Row Count 9 (+ 1) % Row 9 \SetRowColor{white} ptr = \&a; & //ptr pointe sur a \tn % Row Count 10 (+ 1) % Row 10 \SetRowColor{LightBackground} c = *ptr += 2; & //a = 5 c = 5 \tn % Row Count 11 (+ 1) % Row 11 \SetRowColor{white} ptr = \&c; & //ptr pointe sur c \tn % Row Count 12 (+ 1) % Row 12 \SetRowColor{LightBackground} ++ (*ptr); & //c = 6 \tn % Row Count 13 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{\{\{ac\}\}{\bf{a = 5 ; b = 3 ; c = 6}}} \tn % Row Count 14 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{5.377cm}}{\bf\textcolor{white}{Pointeurs \& fonctions}} \tn \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{void decoupe(int {\emph{heures, int }}minutes)\{ \newline {\emph{h = }}m/60; \newline {\emph{m = }}m\%60;\} \newline int main()\{ \newline int h = 0, m = 90; \newline decoupe(\&h, \&m); \newline printf("\%d h et \%d m\textbackslash{}n",h, m);\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{5.377cm}}{`Les pointeur permettent de faire rendre à une fonctions plusieurs "returns" en modifiant directement depuis l'intérieur d'une fonction la valeur d'une variable dans un espace nom différent de celui de la fonction. Le "proper" return est généralement utilisé pour rendre des codes en cas d'erreur.`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{double pointeurs}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Pointe sur l'adresse d'un pointeur} \tn % Row Count 1 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}