Hi,
I am trying to search an array of structures. There are only two elements in the array (structure one and structure two). But I cant seem to get the code to search both. It seems to search the first entry and then stop.
Here is a code snippet:
for (int index = 0; index < arraySize; index++)
{
if (items[index].itemname == stuff )
{
items[index].equip = 'y';
What I want it to do is search the array for "stuff" and if it finds a match, update items[index].equip to a 'y'. It updates the first one, but even though I know im typing in the second entry correctly, It does not find it.
The definition of items:
//Structure decleration
struct bag
{
char itemname[50]; //item name
int stats; //equipment stats
char equip; //Is it equiped? y or n
};
//items of type bag
bag items[NUM_ITEMS];
Here is the code from the loop to the end:
for (int index = 0; index < arraySize; index++)
{
if (items[index].itemname == stuff )
{
items[index].equip = 'y';
fstream bagFile;
bagFile.open("bag.txt", ios::out | ios::binary);
if (bagFile.fail())