ME-dia
ME-dia

Reputation: 289

const_iterator Prolems

I've never used const_iterator before and am having difficulty getting this to debug. Any help is appreciated. Windows 7 and VS 2010 Thank you.

typedef std::basic_string <unsigned char> ustring;
ustring receivedData(data[i], length);
typedef std::map<string, int> MapMime;
MapMime mymap;

mymap["audio/basic"] = 1;
mymap["audio/x-aiff"] = 2;
mymap["audio/x-wav"] = 3;
mymap["video/mpeg"] = 4;
mymap["video/mpeg-2"] = 5;
mymap["video/quicktime"] = 6;

for (MapMime::const_iterator it = mymap.begin(), itEnd = mymap.end();it !=   itEnd.++it);
{
size_t findPosition = receivedData.find(it->first);
if (findPosition != string::npos)
    {
    // Found a match at position findPosition
    }
    else
    {
    // That MIME type was not found in the data...
    }
}

Upvotes: 0

Views: 262

Answers (1)

Pavel Safronov
Pavel Safronov

Reputation: 169

You have an extra semicolon after the for loop, you should remove it. Otherwise, 'it' is defined only inside the for loop, which is empty.

Upvotes: 3

Related Questions