Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8839941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:21:06+00:00 2026-06-14T10:21:06+00:00

I have 2 arrays (both containing 2 strings each) one contains serial numbers from

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T10:21:07+00:00Added an answer on June 14, 2026 at 10:21 am

    With only 4 items in your lists you can keep it simple:

    if(usbArray[0] == textArray[0])
      usbArray[1] = textArray[1];
    else if(usbArray[0] == textArray[1])
      usbArray[1] = textArray[0];
    else if(usbArray[1] == textArray[0])
      usbArray[0] = textArray[1];
    else if(usbArray[1] == textArray[1])
      usbArray[0] = textArray[0];
    

    Basically, change the two that are different.

    And a second solution:

    for(int i=0; i<=1; i++)
      for(int j=0; j<=1; j++)
         if(usbArray[i] == textArray[j])
           usbArray[(i+1)%2] = textArray[(j+1)%2];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have both matrices containing only ones and each array has 500 rows and
I have two text blocks, containing company names. Both contain names of hundreds of
I have two vectors containing strings. I want to compare each string of vector1
I have an array of arrays, each array containing details of a scan by
I have 2 Arrays in 2 variables and both of them containing exactly the
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().
guys i have arrays in which i have to match this kind of text
I have two arrays, @names and @employees , that are filled with strings that
I have a DataTable containing two columns, both of which is a list of
I have two databases, each containing email addresses of users. I've written a script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.