cd cs31/weeklylab pwd mkdir week11 ls cd week11 pwd cp ~newhall/public/cs31/week11/* . ls
Here is some documentation about writing makefiles: Makefiles
Let's open the Makefile you copied over with today's in-class code and
see what it is doing
In C, a string is an array of char with a special terminating null character '\0' that signifies the end of the string. The array of chars can be statically or dynamically allocated (by calling malloc). One thing to remember is to allocate enough space for the terminating null character.
Let's take a look at this code and see what it is doing. Note its uses the ctype and string library functions. C string library functions assume that the caller has allocated space for the result string (note the call to strcpy).
example string library functions: strcmp, strlen, strcpy, strchr, example ctype library functions: isalnum, isdigit, isspace
This code also shows an example of using the readline library to read in a string entered by the user. I have some documentation about the readline library here: using the C readline library. The call to readline returns a string (allocated in heap space) to the caller containing the contents of the input line. It is the caller's responsibility to free this returned string.
See aslo the char and string in C documentation from the "C and Part 1 of intro to C for CS31 students" webpage
Also, make use of man pages for ctype and string library functions to learn more about how to use them.
Try running with some different input strings, for example:
hello 1 2 3 hello 1 2 3 !@ hello x%
Make the substr pointer point to the begining of the first token and try prining it out. One way to set a pointer to point to any bucket in an array is:
ptr = &(array[i]);
Compile and try running with different input strings and see if it works.