Reputation: 442
I need to shorten wchar_t array. Example:
wchar_t* email = L"[email protected]";
/ * 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?
Upvotes: 0
Views: 220
Reputation: 67263
No, that won't create any memory leaks because you aren't allocating any memory, or modifying your original email
pointer.
An easier and more efficient syntax, though, would be *pos = '\0';
Upvotes: 3