/* ptrCast.c illustrates using a pointer to int to access an array of chars. The effect is that any arithmetic done to the int ptr advances in multiples of 4 characters instead of 1. Why? */ #include #include #include int main(int argc, char *argv[]) { char plea[] = "I really don't want to pass this class!"; char *text = (char *)malloc(strlen(plea) + 1); char *m_ptr = (char *)(((int *)text) + 2); printf("%s\n", plea); strcpy(text, plea); strcpy(m_ptr + 1, "_do_"); printf("%s\n", text); return 0; }