📚 The CoCalc Library - books, templates and other resources
License: OTHER
%!TEX root = Programmierparadigmen.tex1\chapter{C}2\index{C|(}3C ist eine imperative Programmiersprache. Sie wurde in vielen Standards4definiert. Die wichtigsten davon sind:56\begin{itemize}7\item C89 wird auch ANSI C genannt.8\item C90 wurde unter ISO 9899:1990 veröffentlicht. Es gibt keine bedeutenden9Unterschiede zwischen C89 und C90, nur ist das eine ein ANSI-Standard10und das andere ein ISO-Standard.11\item C99 wurde unter ISO 9899:1999 veröffentlicht.12\item C11 wurde unter ISO 9899:2011 veröffentlicht.13\end{itemize}1415\section{Datentypen}\xindex{Datentypen}16Die grundlegenden C-Datentypen sind17\begin{table}[H]18\centering19\begin{tabular}{|l|l|}20\hline21\textbf{Typ} & \textbf{Größe} \\ \hline\hline22char & 1 Byte \\ \hline23int & 4 Bytes \\ \hline24float & 4 Bytes \\ \hline25double & 8 Bytes \\ \hline26void & 0 Bytes \\ \hline27\end{tabular}28\end{table}2930zusätzlich kann man \texttt{char}\xindex{char} und \texttt{int}\xindex{int}31noch in \texttt{signed}\xindex{signed} und \texttt{unsigned}\xindex{unsigned}32unterscheiden. Diese werden \textit{Modifier}\xindex{Modifier} genannt.3334In C gibt es keinen direkten Support für Booleans.3536\section{ASCII-Tabelle}\label{sec:ascii-tabelle}37\begin{table}[!h]38\centering39\begin{tabular}{|p{1.0cm}|p{1.0cm}||p{1.0cm}|p{1.0cm}||p{1.0cm}|p{1.0cm}||p{1.0cm}|p{1.0cm}|}40\hline41\textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} \\ \hline\hline420 & ~ & 32 & ~ & 64 & @ & 96 & ' \\ \hline431 & ~ & 33 & ! & 65 & A & 97 & a \\ \hline442 & ~ & 34 & " & 66 & B & 98 & b \\ \hline453 & ~ & 35 & \# & 67 & C & 99 & c \\ \hline464 & ~ & 36 & \$ & 68 & D & 100 & d \\ \hline475 & ~ & 37 & \% & 69 & E & 101 & e \\ \hline486 & ~ & 38 & \& & 70 & F & 102 & f \\ \hline497 & ~ & 39 & ' & 71 & G & 103 & g \\ \hline508 & ~ & 40 & ( & 72 & H & 104 & h \\ \hline519 & ~ & 41 & ) & 73 & I & 105 & i \\ \hline5210 & ~ & 42 & * & 74 & J & 106 & j \\ \hline5311 & ~ & 43 & + & 75 & K & 107 & k \\ \hline5412 & ~ & 44 & , & 76 & L & 108 & l \\ \hline5513 & ~ & 45 & - & 77 & M & 109 & m \\ \hline5614 & ~ & 46 & . & 78 & N & 110 & n \\ \hline5715 & ~ & 47 & / & 79 & O & 111 & o \\ \hline5816 & ~ & 48 & 0 & 80 & P & 112 & p \\ \hline5917 & ~ & 49 & 1 & 81 & Q & 113 & q \\ \hline6018 & ~ & 50 & 2 & 82 & R & 114 & r \\ \hline6119 & ~ & 51 & 3 & 83 & S & 115 & s \\ \hline6220 & ~ & 52 & 4 & 84 & T & 116 & t \\ \hline6321 & ~ & 53 & 5 & 85 & U & 117 & u \\ \hline6422 & ~ & 54 & 6 & 86 & V & 118 & v \\ \hline6523 & ~ & 55 & 7 & 87 & W & 119 & w \\ \hline6624 & ~ & 56 & 8 & 88 & X & 120 & x \\ \hline6725 & ~ & 57 & 9 & 89 & Y & 121 & y \\ \hline6826 & ~ & 58 & : & 90 & Z & 122 & z \\ \hline6927 & ~ & 59 & ; & 91 & $[$ & 123 & \{ \\ \hline7028 & ~ & 60 & < & 92 & \textbackslash & 124 & | \\ \hline7129 & ~ & 61 & = & 93 & $]$ & 125 & \} \\ \hline7230 & ~ & 62 & > & 94 & \textasciicircum & 126 & $\sim$ \\ \hline7331 & ~ & 63 & ? & 95 & \_ & 127 & DEL \\ \hline74\end{tabular}75\end{table}7677\section{Syntax}7879\subsection{Logische Operatoren}80\begin{table}[H]81\centering82\begin{tabular}{CCCC}83UND & ODER & Wahr & Falsch \\ \hline\hline84\&\& & || & 1 & 0 \\[4ex]85GLEICH & UNGLEICH & NICHT & ~ \\ \hline\hline86== & != & ! & ~ \\87\end{tabular}88\caption{Logische Operatoren in C}\xindex{Logische Operatoren!C}89\end{table}9091\section{Präzedenzregeln}\xindex{Präzedenzregeln}%92\begin{tabbing}93\textbf{A} \=\enquote{[name] is a\dots}\\94\>\textbf{B.1} \=prenthesis {\color{red}$( )$}\\95\>\textbf{B.2} \>postfix operators:\\96\> \>\textbf{B.2.1} \={\color{red}$( )$} \=\enquote{\dots function returning\dots}\\97\> \>\textbf{B.2.2} \>{\color{red}$[ ]$} \>\enquote{\dots array of\dots}\\98\>\textbf{B.3} \>prefix operator: {\color{red}*} \enquote{\dots pointer to\dots}\\99\>\textbf{B.4} \>prefix operator {\color{red}*} and {\color{red}\texttt{const} / \texttt{volatile}} modifier:\\100\> \>\enquote{\dots [modifier] pointer to\dots}\\101\>\textbf{B.5} \>{\color{red}\texttt{const} / \texttt{volatile}} modifier next to type specifier:\\102\> \>\enquote{\dots [modifier] [specifier]}\\103\>\textbf{B.6} \>type specifier: \enquote{\dots [specifier]}104\end{tabbing}105106\texttt{static unsigned int* const *(*next)();}107108\begin{table}[htp]109\centering110\begin{tabular}{lll}111A & \texttt{next} & next is a \\112B.3 & \texttt{*} & \dots pointer to\dots \\113B.1 & \texttt{( )} & \dots \\114B.2.1 & \texttt{( )} & \dots a function returning\dots \\115B.3 & \texttt{*} & \dots pointer to\dots \\116B.4 & \texttt{*const} & \dots a read-only pointer to\dots \\117B.6 & \texttt{static unsigned int} & \dots static unsigned int. \\118\end{tabular}119\end{table}120121\section{Beispiele}122\subsection{Hello World}123Speichere den folgenden Text als \texttt{hello-world.c}:124125\inputminted[linenos, numbersep=5pt, tabsize=4, frame=lines, label=hello-world.c]{c}{scripts/c/hello-world.c}126127Compiliere ihn mit \texttt{gcc hello-world.c}. Es wird eine ausführbare128Datei namens \texttt{a.out} erzeugt.129130\subsection{Pointer}131\inputminted[linenos, numbersep=5pt, tabsize=4]{c}{scripts/c/pointer.c}132133Die Ausgabe hier ist \texttt{0 3}.134\index{C|)}135136137138