This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: printf("%d\n", arrayq - arrayp); Note: arrayp += 3 makes them equal. The unit is not bytes, but sizeof(*arrayp). BUT: int intp = arrayp; // NOT int* int intq = arrayq; printf("%d\n", intq - intp); Undefined! But universally not 3. Expect 3 * sizeof(array) Parameters. prototype: int strcount(char str, char what); but call is strcount(arrayp, ' ') It's okay. arrayp is cast to char, which you can't do with an assignment, only with a parameter. How about int words(char *strp)? words(string) okay? sure. it's cast by assignment, as we did earlier If there's time: Incomplete types Multi-dimensional arrays Why they're not frequently used or seen NOTE: we already saw assignment among pointer types, but that's not portable. What we CAN count on is void *temp; temp = anypointer; anypointer = temp; and anypointer is back as it began. LAB: write the (my)strcmp function. give it string pointers and arrays. vim: set sts=4 sw=4 ai et :...
View Full Document
- Spring '09