/* CSE 303, Spring 2009, Marty Stepp This program plays with string copying. */ #include #include int main(void) { // yes v char s1[8]; strcpy(s1, "hello"); // [ g o o d b y e \0 ] // s1 --> &s[0] strcpy(s1, "goodbye"); // no! char* s2 = "hello"; // s2 --> "h e l l o \0" strcpy(s2, "goodbye"); // yes char* s3 = (char*) calloc(12, 1); strcpy(s3, "hello"); // s3 --> "h e l l o \0 \0 \0 ..." strcpy(s3 + 2, "goodbye"); // s3 --> "h e g o o d b y e \0 \0..." return 0; }