Elysia demonstrated a char array as a local variable. Only use it as a local variable for small amounts of memory (maybe up to 1 Kbyte).
I-See-C, the code you posted is way too overcomplicated (and yeah, it's bad code lol).
And this is it!Code:char word[]={"abcdefghijklmnopqrstuvwxyz"}; //the compiler calculates the length itself here //(and adds a NULL terminator), don't worry about it ptr=malloc(sizeof(word) * sizeof(char)); if(ptr==NULL){ printf("err"); } else{ strcpy(ptr,word); //strcpy copies a whole string, not only one char printf("%s\n",ptr); //%s = char* (so yes, no *) free(ptr); }
Edit: Oops, sizeof and strlen mixed, sorry.![]()



