string copy rodoes not work in c : I tried below code to copy string in c but I am not getting correct result.

    #include <stdio.h>
    #include <string.h>
    #include <stdlib.h>
    int main(void){
    char *string1;
    char *string2 = "abcdefghijk";
    char *ptr = string2;
    unsigned int no_of_chars =0;
    while(*ptr++ !='\0'){
        no_of_chars++;
    }
    string1 = malloc(sizeof(char)*(no_of_chars+1));
    while(*string1++ = *string2++);
    printf("string2=%s\n",string2);
    printf("string1=%s\n",string1);
    return 0;
    
    }