I searched all over StackOverflow but could not find exactly what I am trying to do. I'd like to copy pointer Items over to pointer COPYTO. Then able to call COPYTO->x.
#include <stdio.h>
typedef struct JustArray {
char x[30];
} JustArray;
int main()
{
JustArray *Items, *COPYTO;
char d[10] = "Test";
Items = malloc(sizeof(Items));
COPYTO = malloc(sizeof(COPYTO));
strcpy(&Items->x,d);
memmove(©TO, Items, sizeof(JustArray));
printf("Pointer: %p\n", &d);
printf("Address: %u\n",&d);
printf("Value: %s\n", Items->x);
printf("Value: %s\n", COPYTO->x);
return 0;
}
This program compiles but will not run. It have a popup saying: Access violation reading location 0xabababab.
I came from C# and finding C to be incredibly difficult to understand......