vendredi 1 juillet 2016
I have a vector that is filled up within a loop. When I step through the code, the final vector looks different to when I let the code run
To elaborate, I have a global vector defined above main as: vector<PCWSTR> objectIdentifiers (I have no experience with PCWSTR, but this is the format used by the windows portable devices API).
I have a line within a function recursiveEnumerate() that fills in the vector like so:
objectIdentifiers.push_back(objectID);
Where objectID is a PCWSTR.
I have placed a breakpoint in Visual studio on this line, and the vector fills up every loop correctly. I stepped through code until the size of objectIdentifiers was 10, and this is what it looks like in the debugger:
Which seems fine, since there are very few gaps.
When I run the code without placing a breakpoint on the line, and instead placing a breakpoint at the very end of main, when I watch the vector, I get this:
The first object is correct (L"DEVICE"), but I'm not entirely sure what has happened afterward. The result appears to be different every time, except for the first entry (which is always L"DEVICE").
I'm guessing the reason is that I'm adding entries to the vector incorrectly. Is using push_back to add PCWSTR's to a vector causing these problems?
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire