Hello I'm very new to C and I'm doing practice problems to improve my understanding. I've been stuck on a question about dynamic memory allocation and pointers, I want to set the value at ptr's to the string "12345678" but I dont want to alter ptr's memory address. I've tried the following methods but I always end up changing its address. What would be the right way to do something like this?
Code:char *ptr = malloc(20*(sizeofchar)); ptr="12345678";Code:char *ptr = malloc(20*(sizeofchar)); char *x=&ptr; x="12345678";