Lines 99 and 100 have this error when compiling. I have posted the
code, Does anyone know what this error means? How do I fix it? I
trying to Use pointer notation rather than array notation while
traversing the arrays.  






//MODE vs MEDIAN  pg.632
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;

void sortArray1(int *, int );
void showArray1(int *, int );

int main()
{   
    ifstream file1; //used to read from data file numbers_1
//    ifstream file2; //used to read from data file number_2
//    ifstream file3; //used to read from data file number_3
    const int num_commuters=50; //number of comuters
    int mile1[num_commuters];
//    int mile2[num_commuters];
//    int mile3[num_commuters];
    int count;

    //open file 1
    file1.open("numbers_1.txt");
    if (!file1)
      cout <<"Error opening file\n";
    else
    {
      for (count=0; count < num_commuters; count++)
         file1 >> *(mile1+count);
         
    //open file 2
//        file2.open("numbers_2.txt");
//    if (!file2)
//      cout <<"Error opening file\n";
//    else
//    {
//      for (count=0; count < num_commuters; count++)
//         file1 >> *(mile2+count);
// 
        
//    //open 3     
//        file3.open("numbers_3.txt");
//    if (!file3)
//      cout <<"Error opening file\n";
//    else
//    {
//      for (count=0; count < num_commuters; count++)
//         file1 >> *(mile3+count);
      
      //close all files        
      file1.close();
//     file2.close();
//      file3.close();
      
      //display output
     
    } 
 //table
     cout <<"                        Medians    :      Modes" << endl;
    cout <<"                        _________________________" << endl;
    cout <<"File 1 numbers_1.txt" <<"               :           " << endl;
    cout <<"File 2 numbers_2.txt" <<"               :           " << endl;
    cout <<"File 3 numbers_3.txt" <<"               :           " <<
endl;  
    cout << endl;
    cout <<"Average Median: " << endl;
    cout <<"Average Mode: " << endl <<endl;
    cout <<"     Orignal List           :            Sorted List" << endl;
    cout
<<"__________________________________________________________" << endl;
    cout <<"File 1    File 2    File 3  :  File 1    File 2    File 3"
<< endl;
    cout <<"______    ______    ______  :  ______    ______    ______"
<< endl;  
   //see out file 1
    for(count =0; count < num_commuters; count++)
      {
        cout << "  " << *(mile1+count) << endl;
        
      }
    

    system ("pause");
    return 0;
}
//}
//}
//*****************
//sort the pointer*
//*****************
void sortArray1(int *mile1, int size)
{
     int temp;
     bool swap;
     
     do 
     {
          swap = false;
          for (int count = 0; count < (size -1); count++)
          {
            if(*mile1+count > *mile1+(count+1))
            {
                temp = *mile1+count;
                *mile1+count = *mile1+(count + 1);
                *mile1+(count + 1) = temp;
                 swap = true;                   
            }           
          }
     } 
     while (swap);
}
//*****************
//show the pointer*
//*****************
void showArray(int *mile1, int size)
{
  for (int count = 0; count < (size-1); count++)
      cout << *mile1+count << endl;     
}
     
 

 


Reply via email to