November 2013
Beginner
325 pages
9h 47m
English
A C string is just a bunch of characters right next to each other in memory. The string ends when the character 0x00 is encountered.
Figure 39.1 The word “Love” as a C string
Functions that take C strings expect the address of the string’s first character. strlen(), for example, will count the number of characters in a string. Try building a string and using strlen() to count the letters:
#include <stdio.h> // For printf
#include <stdlib.h> // For malloc/free
#include <string.h> // For strlen int main (int argc, const char * argv[]) { char x = '!'; // The character '!' while (x <= '~') { // The character '~' printf("%x ...Read now
Unlock full access