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 email
pointer.
An easier and more efficient syntax, though, would be *pos = '\\0';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.