Lab 2 - Strings
string_array + 2 == 0x
string_array[0] + 5 == 0x
string_array[2] + 10 == 0x
What does each of the things look like right now.
What does this drawing look like?
One function
char** camel_caser(const char *input_str);
Input: A sequence of space seperated words Output: A camelcased version of that sequence
Example Input: “Do not go gentle into that good night” Example Output: “doNotGoGentleIntoThatGoodNight”
Maybe we don’t want to pass around the size of the array everywhere. We also know that NULL is not a valid string, this is not true in all cases.
char **ptr = ...;// vs
int *arr = ...;
arr[len] = NULL; //NULL = 0, meaning we have a valid element
Write Tests and then write the actual code to make your tests pass.
strdup
: return a string copy.strcpy
,strncpy
: copy a string to another string.toupper
, tolower
: return the upper/lower of input character.ispunct
,isspace
,isalpha
: decide whether it is punct/alpha/space.
Be carefull of strtok