// A revision exercise to cover char pointers // Lecture Week 10 Monday #define MAX 128 #include #include #include // How do we work with s2? // Can s2 store a copy of s0? int main (int argc, char *argv[]){ char s0[] = "abcd"; char s1[MAX]; char *s2; char *s3; s2 = s0; printf("%s\n", s2); s2[0] = 'z'; printf("s0: %s\n", s0); printf("s2: %s\n", s2); s3 = malloc(sizeof(char) * (strlen(s0) + 1)); strcpy(s3, s0); s3[2] = '?'; printf("s0: %s\n", s0); printf("s2: %s\n", s2); printf("s3: %s\n", s3); f(s0); return 0; }