Hey, ive debugged my program to this line, and im not sure what to use, strcpy or some other thing, but i need to get the string from a[x] in to the new string c[z]. Any suggestions?

string a[100];
string c[100];

      if (a[x].compare(b[y])==0)
        {
	  c[z] = a[x];  //doesnt work
          z++;
        }

I have also attached the full program if needed. Thank you
-Scott

[edit]
The line highlighted should actually work. It's ok to assign one std::string to another with the = operator.

Looking through your program, I do see some other issues:

void getData(ifstream& data, string array[100], int n)
{  
    n=0;
    while(!data.eof())
    {
        data >> array[n];
        if(data.peek()=='\n')
        {
            break;
        }
        n++;        
    }
}

You should pass the second argument by reference, else the data will be lost upon exiting the function.
Data.eof() is never a good idea. And since you're looking for "\n"'s maybe you could betetr use getline():

int array_counter = 0;
string buffer;
while (getline(data, buffer))
{
  in_array[array_counter] = buffer;
  array_counter++;
}

Sorry, but parameter string array[100] is equivalent of pointer to array of strings passing, so it's correct way to go...

The function getdat works fine... if you print the data to screen using a for loop, you can see that the information is being stored correctly in the arrays.

void getData(ifstream& data, string array[100], int n)
{  
  n=0;
  while(!data.eof())
    {
      data >> array[n];
      if(data.peek()=='\n')
        {
          break;
        }
      n++;        
    }
    //test!
    for (int x=0;x<=n;x++)
      {
        cout << array[x] << endl;
      }
}

Lines 32,33 of your code
getData(data, a, counterA);
getData(data, b, counterB);
1. counterA and counterB are both 0, and will remain so after the call. Is this counter a limit or a result?
2. the while eof() thing in the function will ensure a gets all the data, and b none of it
3. the while eof() thing (as neik_e points out) means you go round the loop one extra time.

At the very least, getData() needs to limit the amount of data added to the array with

while ( n < 100 && getline(data,buffer) ) {
}

Oh, and replace the goto in main with another while loop.

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.