July 2015
Intermediate to advanced
380 pages
10h 15m
English
In the last exercise, you did math but with, a '\0' (nul) character. This may seem odd if you’re coming from other languages, since they try to treat strings and byte arrays as different beasts. C treats strings as just arrays of bytes, and it’s only the different printing functions that recognize a difference.
Before I can really explain the significance of this, I have to introduce a couple more concepts: sizeof and arrays. Here’s the code we’ll be talking about:
ex12.c
1 #include <stdio.h> 2 3 int main(int argc, char *argv[]) 4 { 5 int areas[] = { 10, 12, 13, 14, 20 }; 6 char name[] = "Zed"; 7 char full_name[] = { 8 'Z', 'e', 'd', 9 ...