C.tex 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. %!TEX root = Programmierparadigmen.tex
  2. \chapter{C}
  3. \index{C|(}
  4. C ist eine imperative Programmiersprache. Sie wurde in vielen Standards
  5. definiert. Die wichtigsten davon sind:\todo{Wo sind unterschiede?}
  6. \begin{itemize}
  7. \item C89
  8. \item C99
  9. \item ANSI C
  10. \item C11
  11. \end{itemize}
  12. \section{Datentypen}\xindex{Datentypen}
  13. Die grundlegenden C-Datentypen sind
  14. \begin{table}[htp]
  15. \centering
  16. \begin{tabular}{|l|l|}
  17. \hline
  18. \textbf{Typ} & \textbf{Größe} \\ \hline\hline
  19. char & 1 Byte \\ \hline
  20. int & 4 Bytes \\ \hline
  21. float & 4 Bytes \\ \hline
  22. double & 8 Bytes \\ \hline
  23. void & 0 Bytes \\ \hline
  24. \end{tabular}
  25. \end{table}
  26. zusätzlich kann man \texttt{char}\xindex{char} und \texttt{int}\xindex{int}
  27. noch in \texttt{signed}\xindex{signed} und \texttt{unsigned}\xindex{unsigned}
  28. unterscheiden.
  29. \section{ASCII-Tabelle}\label{sec:ascii-tabelle}
  30. \begin{table}[htp]
  31. \centering
  32. \begin{tabular}{|l|l||l|l||l|l||l|l|}
  33. \hline
  34. \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} & \textbf{Dez.} & \textbf{Z.} \\ \hline\hline
  35. 0 & ~ & 31 & ~ & 64 & @ & 96 & ' \\ \hline
  36. 1 & ~ & ~ & ~ & 65 & A & 97 & a \\ \hline
  37. 2 & ~ & ~ & ~ & 66 & B & 98 & b \\ \hline
  38. 3 & ~ & ~ & ~ & ~ & C & 99 & c \\ \hline
  39. 4 & ~ & ~ & ~ & ~ & D & 100 & d \\ \hline
  40. 5 & ~ & ~ & ~ & ~ & E & ~ & ~ \\ \hline
  41. 6 & ~ & ~ & ~ & ~ & F & ~ & ~ \\ \hline
  42. 7 & ~ & ~ & ~ & ~ & G & ~ & ~ \\ \hline
  43. 8 & ~ & ~ & ~ & ~ & H & ~ & ~ \\ \hline
  44. 9 & ~ & ~ & ~ & ~ & I & ~ & ~ \\ \hline
  45. 10 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  46. 11 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  47. 12 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  48. 13 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  49. 14 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  50. 15 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  51. 16 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  52. 17 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  53. 18 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  54. 19 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  55. 20 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  56. 21 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  57. 22 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  58. 23 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  59. 24 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  60. 25 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  61. 26 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  62. 27 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  63. 28 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  64. 29 & ~ & ~ & ~ & ~ & ~ & ~ & ~ \\ \hline
  65. 31 & ~ & ~ & ~ & ~ & ~ & 127 & ~ \\ \hline\hline
  66. \end{tabular}
  67. \end{table}
  68. \section{Syntax}
  69. \section{Beispiele}
  70. \subsection{Hello World}
  71. Speichere den folgenden Text als \texttt{hello-world.c}:
  72. \inputminted[linenos, numbersep=5pt, tabsize=4, frame=lines, label=hello-world.c]{c}{scripts/c/hello-world.c}
  73. Compiliere ihn mit \texttt{gcc hello-world.c}. Es wird eine ausführbare
  74. Datei namens \texttt{a.out} erzeugt.
  75. \index{C|)}