I need to shorten wchar_t array. Example:
wchar_t* email = L"name@domain.com";
/ * Somehow leave in email just "name" * /
My idea to do that
wchar_t Domain = L"@domain.com";
if(!(pos = wcsstr(email, Domain)))
return 0;
wcsncpy (pos,L"",1);
wcsstr returns address to “@domain.com”(0x000001 – email begins, 0x000005 @domain.com begins ) but there wont be any memory leaks or garbage?
No, that won’t create any memory leaks because you aren’t allocating any memory, or modifying your original
emailpointer.An easier and more efficient syntax, though, would be
*pos = '\0';