I am confused, I seem to be losing the variable item.Size when i go from one for loop to the next....why?

When i show item.Size the first time it shows all the #s, the second time I get straight 0s?

for (unsigned long int q = 0; q < tableCount; q++)
    {
		for each (AoE2Wide::DrsItem item in inTables[q].Items)
        {
			inFileDrs.read(reinterpret_cast<char*>(&id),sizeof(id));
			inFileDrs.read(reinterpret_cast<char*>(&start),sizeof(start));
			inFileDrs.read(reinterpret_cast<char*>(&size),sizeof(size));
			item.Id = id;
			item.Start = start;
			item.Size = size;
			std::cout << item.Size << std::endl;
        }
    }

//	char *tempItem = new char[1];
//	delete [] tempItem;
    for (unsigned long int q = 0; q < tableCount; q++)
    {
		for each (AoE2Wide::DrsItem item in inTables[q].Items)
        {
			std::cout << item.Size << std::endl;

//			tempItem = new char [item.Size];
//			inFileDrs.read(tempItem, item.Size);
			//item.Data.push_back(*tempItem);
//			for (unsigned long int k = 0; k < item.Size; k++)
//				item.Data.push_back(tempItem[k]);
//			delete [] tempItem;
			//std::cout << item.Data.size() << std::endl;
			/*******************POSSIBLE ERROR ********************/
		}
	}

You're not actually modifying the inTables[q].Items in your first loop.

for each (AoE2Wide::DrsItem item in inTables[q].Items)
{
   // item is a copy of what's at inTables[q].Items, modifying item will leave the item in inTables[q].Items in tact
}

So how am i supposed to edit it this way?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.