Here is my working code. Do I need to clear or free wstring, wstringstream, vector in the func()? If so, how? I see there is a .clear() function for the vector and wstring and wstream.
This sample program is to show the code. I use the wstringstream, wstring, and vector where I have a delimited-string and I need to extract and act on each item in the list.
Any suggestions for optimizing this code and/or doing housekeeping is appreciated too.
#include <windows.h>
#include <strsafe.h>
#include <vector>
#include <sstream>
using namespace std;
void func()
{
    WCHAR sComputersInGroup[200] = L"PC1|PC2|PC3|PC4|";
    WCHAR sSN[200]{};
    wstringstream wSS(sComputersInGroup);
    wstring wOut;
    vector<wstring> vComputer;
    while (wSS.good())
        {
        getline(wSS, wOut, L'|');
        vComputer.push_back(wOut);
        }
    INT i = 0;
    while (i < (INT) vComputer.size())
        {
        if (vComputer[i].length() > 0)
            {
            StringCchCopy(sSN, 16, vComputer[i].c_str());
            }
        i++;
        }
}
int main()
{
    for (INT i=0;i<20000;i++)
        func();
}
 
    