I'm trying to simply add an integer to a pointer, and the compiler continues to force multiplying the integer by 2, then adding it. I assume the compiler is automating the pointer arithmetic, but it's causing issues
Code:
char *Char1 = "Test123456789";
int new_int = 2;
char *Char2 = (char*)(Char1+new_int);
MessageBoxA(0,Char2,0,0);
In this example, Char2 points to "123456789", when I want it to point to "st123456789". The compiler is deciding to multiply new_int by 2 before adding it to Char1
I also tried:
char *Char2 = &Char1[new_int];
With the same problem...
Compiler is Microsoft Visual Studio 6
Aucun commentaire:
Enregistrer un commentaire