From c7c71500ed8e27c2b12a4d5369ab5564d751e060 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Sun, 18 May 2014 20:58:49 +0200 Subject: [PATCH] initial commit of examples from chapter 5 --- c_pointers/chapter_5.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 c_pointers/chapter_5.c diff --git a/c_pointers/chapter_5.c b/c_pointers/chapter_5.c new file mode 100644 index 0000000..c3adceb --- /dev/null +++ b/c_pointers/chapter_5.c @@ -0,0 +1,26 @@ +#include +#include +#include + + +int main(void) { + + // print size of char & character literal + printf("%zu\n", sizeof(char)); + printf("%zu\n", sizeof('a')); + + + + // when a string is not a constant + // doesn't work with gcc anymore, also with -Wno-deprecated-writable-strings + // gives 'Bus error: 10' + { + char *tabHeader = "Sound"; + *tabHeader = 'L'; + printf("%s\n", tabHeader); + } + + + return 0; + +} \ No newline at end of file