Browse Source

initial commit of examples from chapter 5

master
T. Meissner 11 years ago
parent
commit
c7c71500ed
1 changed files with 26 additions and 0 deletions
  1. +26
    -0
      c_pointers/chapter_5.c

+ 26
- 0
c_pointers/chapter_5.c View File

@ -0,0 +1,26 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
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;
}

Loading…
Cancel
Save