From mboxrd@z Thu Jan 1 00:00:00 1970 From: "J." Subject: *w[1]++ = *[k[1]++; does not work .. ? Date: Sun, 23 Feb 2003 18:37:08 +0100 (CET) Sender: linux-c-programming-owner@vger.kernel.org Message-ID: Mime-Version: 1.0 Return-path: List-Id: Content-Type: TEXT/PLAIN; charset="us-ascii" Content-Transfer-Encoding: 7bit To: linux-c-programming@vger.kernel.org Hello... I am trying to copy a string into the first element of an array of char pointers. I can print char by char like this: printf("%c", *w[1]++); but I can not copy char by char like this: *w[1]++ = *k[1]++; I dont understand ? If I can print it, it should also copy .. Strangly enough the compiler does not complain. I have inserted a small illustrative example in this e-mail. /* To illustrate the difference: This works */ #include #include int main(void) { char *w[1]; char str[] = "jehova"; w[1] = strdup(str); while(*w[1] != '\0') printf("%c", *w[1]++); printf("\n"); return 0; } /* But this does not work */ #include #include #include int main(void) { char *w[1]; char *k[1]; char str[] = "jehova"; w[1] = strdup(str); k[1] = calloc(strlen(str) + 1, sizeof(char)); while(*w[1] != '\0') *k[1]++ = *w[1]++; printf("%s\n", w[1]); return 0; } Can someone explain what I am doing wrong ? Thankx a lot,... J.