updated C2
authorChristian Urban <christian dot urban at kcl dot ac dot uk>
Mon, 06 Oct 2014 22:57:44 +0100
changeset 216 38718062709a
parent 215 06cc38192865
child 217 8ddf4fe6bf31
updated C2
handouts/ho03.pdf
progs/C1.c
progs/C2a.c
slides/slides03.pdf
slides/slides03.tex
Binary file handouts/ho03.pdf has changed
--- a/progs/C1.c	Mon Oct 06 22:48:09 2014 +0100
+++ b/progs/C1.c	Mon Oct 06 22:57:44 2014 +0100
@@ -1,17 +1,18 @@
-void foo (char *bar)
-{
-  float my_float = 10.5;  // in hex: \x41\x28\x00\x00
-  char  buffer[28];        
+#include <string.h>
+#include <stdio.h>
+
+void dead () {
+  printf("I will never be printed!");
+}
+
 
-  printf("my float value = %f\n", my_float);
-  strcpy(buffer, bar);  
-  printf("my float value = %f\n", my_float);
-}
- 
-int main (int argc, char **argv)
-{
-  foo("my string is too long !!!!! ");
-  return 0;
+int main(int argc, char **argv) {
+
+  char buffer[8];
+
+  strcpy(buffer, argv[1]);
+
+  return 1;
 }
 
 
--- a/progs/C2a.c	Mon Oct 06 22:48:09 2014 +0100
+++ b/progs/C2a.c	Mon Oct 06 22:57:44 2014 +0100
@@ -1,7 +1,9 @@
+int i;
+char ch;  
+
 void get_line(char *dst) {
   char buffer[8];
-  int i = 0;
-  char ch;
+  i = 0;
   while ((ch = getchar()) != '\n') {
     buffer[i++] = ch;
   }
Binary file slides/slides03.pdf has changed
--- a/slides/slides03.tex	Mon Oct 06 22:48:09 2014 +0100
+++ b/slides/slides03.tex	Mon Oct 06 22:57:44 2014 +0100
@@ -230,6 +230,10 @@
 \begin{frame}[c]
 \frametitle{What the Hell Is Going On?}
 
+\begin{itemize}
+\item Let's start with a very simple program:
+\end{itemize}
+
 \lstinputlisting[language=C,xleftmargin=4mm]{../progs/example1.c}
 
 \end{frame}