szLnk is an array of WChar. Arrays do not have member functions, so it does not have an erase member function.
This might work for you:
1 2 3 4 5 6 7 8 9 10 11 12
int wmain(int argc, const WCHAR *argv[])
{
....
WCHAR szLnk[1024];
_snwprintf_s(szLnk, sizeof(szLnk), wcschr((constwchar_t*)argv[3], L'\\'));
szLnk++; // now, szLnk is pointing at the SECOND wchar in the array.
....
}
or you could change your _snwprintf_s function call so that you don't start from the beginning of the array you're copying, but skip the first character to begin with.
Or create another array, WCHAR szLnk2[1024];, and copy into it everything except the first character:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int wmain(int argc, const WCHAR *argv[])
{
....
WCHAR szLnk[1024];
_snwprintf_s(szLnk, sizeof(szLnk), wcschr((constwchar_t*)argv[3], L'\\'));
WCHAR szLnk2[1024];
for (int i = 1; i < 1024; ++i)
{
szLnk2[i-1]= szLnk[i];
}
}
Lots of options. The big mistake you're making is thinking that szLnk is some kind of C++ object with member functions like erase. It isn't. It's a plain array.
@Repeater, You can't increment an array name. And _snwprintf_s needs the size in words (not chars/bytes). So maybe something like:
1 2 3 4
WCHAR lnk[1024];
auto p = wcschr(argv[3], L'\\');
if (!p) { /* error: no backslash in third argument */ }
_snwprintf_s(lnk, sizeof lnk / sizeof lnk[0], p + 1);
Now tell me you're a navy seal and you're going to track me down, but do it by private mail so nobody else has to put up with it. I won't read it, but you'll feel better.