H
Harry Overs
My program needs to take a pointer to BYTE array (unsigned char*) and
convert it into a STL list so that each BYTE in the array has its own
element in the list, i.e. if the array has hundred bytes then the list needs
to have a hundred entries, at present when I try to do this each element in
my list points to the entire BYTE array, when what I really need is copies
of each single BYTE in its own part of the list.
I have used code similar to the following for when the list was only used
locally:
std::list<char> m_STLList;
for (int nByteCount = 0; nByteCount < entries_in_array; nByteCount++)
{
char pByte = *(pByteArray + nByteCount);
m_STLList.push_back(pByte);
}
however I now need the list to be returned and then the contents of it
deleted by a different method in another class.
Does anyone know how I can do this?
cheers,
Andy
convert it into a STL list so that each BYTE in the array has its own
element in the list, i.e. if the array has hundred bytes then the list needs
to have a hundred entries, at present when I try to do this each element in
my list points to the entire BYTE array, when what I really need is copies
of each single BYTE in its own part of the list.
I have used code similar to the following for when the list was only used
locally:
std::list<char> m_STLList;
for (int nByteCount = 0; nByteCount < entries_in_array; nByteCount++)
{
char pByte = *(pByteArray + nByteCount);
m_STLList.push_back(pByte);
}
however I now need the list to be returned and then the contents of it
deleted by a different method in another class.
Does anyone know how I can do this?
cheers,
Andy