When I run the follwing code:

#include <iostream.h>
#include <string.h>
#include <vector.h>
#include <fstream.h>
using std::string;
using std::vector;
void exchange(vector <int> &array,vector<string>&array1);
void main()
{
	  ifstream fin,f2,f3,f4;
	  //First name input
	  vector <string> fname(25);
	fin.open("firstname.dat", ios :: in); 
	for( int i= 0;i<25;i++)
		fin>>fname[i];
	fin.close();
	//Second name input
	  vector <int> fnum(25);
	f2.open("firstnum.dat", ios :: in); 
	for(int i= 0;i<25;i++)
		f2>>fnum[i];
	f2.close();
	//Third Name
	exchange(fnum,fname);
	  vector <string> lname(25);
	f3.open("lastname.dat", ios :: in); 
	for( int i= 0;i<25;i++)
		f3>>lname[i];
	f3.close();
	//Forth Name
	  vector <int> lnum(25);
	f4.open("lastnum.dat", ios :: in); 
	for( int i= 0;i<25;i++)
		f4>>lnum[i];
	f4.close();	
	exchange(lnum,lname);	
	for(int i=0;i<25;i++)
		cout<<fname[i]<<'\t'<<lname[i]<<'\t'<<lnum[i]<<endl;
}
	
void exchange(vector <int> &array,vector<string>&array1)
{
     int i, j;
     int temp;   // holding variable
     string temp1;
     int arrayLength = array.length(); 
     for (i=0; i< (arrayLength -1); i++)    // to represent element to be compared
    {
          for(j = (i+1); j < arrayLength; j++)   // to represent the rest of the elements
         {
                if (array[i] < array[j])
               {
                        temp= array[i];          // swap
                        array[i] = array[j];
                        array[j] = temp;
                        temp1= array1[i];          // swap
                        array1[i] = array1[j];
                        array1[j] = temp;
               }
          }
     }
     return;
}

WHen I run it says "Error: undefined identifier 'length'", it is also highlighted in green above
please help the files used are attached below

it's right. vector doesn't have a method named "length()". it does have a method named "size()".

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.