I have 2 arrays (both containing 2 strings each) one contains serial numbers from a USB. the other contains serial numbers from a text file. I was able to retrieve them both successfully. So here’s my problem: I need to compare them to each other, find exactly one serial number that differs, and replace it. like this:
Contents (Dummy Serial numbers)
________
USB | A | B
TXT | B | C
As you can see, the USB and TXT array both contain one of the same serial number (B). That part is easy; I however need to write code to see that C != A and then I need A to replace C.
I tried this:
for (int x = 0; x < 2; x++)
{
for (int y = 0; y < 2; y++)
{
//checks for same serial number
if (m_AttachedUSB[x] == m_Existing_Serial_Numbers[y])
{
//found one
IntOnlyOne++;
//we want this one to stay beacause it has a serial number
//that matches one in the .txt file
m_ChachedUSB = m_AttachedUSB[x];
}
}
}
This however only finds the serial numbers that are similar. How do I replace the ones that are different?
With only 4 items in your lists you can keep it simple:
Basically, change the two that are different.
And a second solution: