I feel like I've always used strcpy to copy strings without having any trouble, but I haven't done it for a long time and now I can't get it to work no matter what I do.
I'm sure there's something dumb I'm missing, but I've been frustrated with this for a while so I'm here to see if anybody else can help.
const char* src = "Lalalala";
int strLen = strlen(src);
char* dest = new char[strLen + 1];
ZeroMemory(dest, strLen + 1);
strcpy_s(dest, strLen, src);
This code throws me an exception saying that the lBuffer is too small. Even if I try copying just "one byte" of data, and allocate a buffer of 128 bytes, it throws the same exception.
Also, I've checked that strlen returns the expected value, the allocation and the "ZeroMemory" function call work fine, and it's only when running the strcpy_s() function that the program crashes. I don't know what's going on here, please help!
Thanks