You don't understand pointers correctly, I think.
Code:
//x86 compatible only, haters gonna hate
DWORD *dwPtr = (DWORD *)0xDEADBEEF; //writing 0xDEADBEEF into the variable dwPtr (or: at address of dwPtr)
*dwPtr = 5; //writing 5 at address 0xDEADBEEF
const char *cstrVal = "C-Style-String";
const char *strPtr = (const char *)0xDEADBEEF; //writing 0xDEADBEEF into the variable strPtr (or: at address of strPtr)
strPtr = cstrVal; //writing the address of "C-Style-String" into the variable strPtr (or: at the address of strPtr) - NOT writing the content ("C-Style-String") at the address saved in strPtr (0xDEADBEEF)
A C-Style string is simply a pointer to a char-Array or rather to the first element of that array. The pointer works exactly the same way an int* does.
Code:
char *strPtr = (char *)0xDEADBEEF; //now leaving out const to make the ptr writeable
*strPtr = *cstrVal; //writing the 'C', the first character of the string pointed to by cstrVal (because it is actually a pointer to that one char) at 0xDEADBEEF
You wouldn't think that
Code:
DWORD vals[] = { 1, 2, 3 };
dwPtr = vals;
//or
*dwPtr = *vals;
would copy the whole DWORD array either, would you?
Of course not. You need a loop for that. Luckily, there is already a well-optimized solution for that provided by the standard library: memcpy/strcpy/strcpy_s.
Btw.
Code:
char *helVal = "Hello";
Your compiler should complain about that line, because you are implicitly converting a const char* into a non-const char* there, which is not possible.
Anyway, #closed