Hello I'm trying read data from a file and display it into 3 arrays coloums. however I keep on getting an error on line 33 stating [expected primary-expression before "int,double,int,int"] [ISO C++ forbids declaration of `readHousehold' with no type] I cant figure it out but I know it has to do with my functions. Thank you so much!

here is the prompt

The results of a survey( in a file) of the households in your township are available for public scrutiny. Each record contains data for one household, including a four-digit integer identification number, the annual income for the household , and the number of household members ( int, double, int). Write a program to read the survey results into three arrays and perform the following analysis (irrelevant as of now).

Here's my code

#include <iostream>
#include <iomanip>
#include <fstream>


using namespace std;

int readHousehold(ifstream &inFile,int idhouseholdArray[], double incomeArray[], int membersArray[], int size);
void   displayhouseData(int idhouseholdArray[], double incomeArray[], int membersArray[]);

const int OK = 0;

int main()
{
  int rc;

  int idhouseholdArray[24] = {1041,1062,1327,1483,1900,2112,2345,3210,3600,3601,4724,6217,9280,1000,1200,5601,5724,5217,5280,5000,5200,5230,6641,7000};

  double incomeArray[24] ={12180,13240,19800,22458,17000,18125,15623,3200,6500,11970,8900,10000,6200,30000,35000,51970,66900,10000,70000,100000,25000,120000,85000,45500};

  int membersArray[24] ={4,3,2,8,2,7,2,3,5,2,3,2,1,3,2,9,3,2,1,6,3,6,7,4};

    ifstream inFile;                             // create an input file object

    cout << fixed
         << showpoint
       << setprecision(2);

    inFile.open("Bonus-Program.txt");                // open the file read

    if (!inFile.fail())                         // if open was successful
    {                                           // execute statements in true path
        rc = readHousehold(inFile, int idhouseholdArray[24], double incomeArray[24], int membersArray[24], int size);
        if (rc == OK) 
            displayhouseData(idhouseholdArray, incomeArray, membersArray);
        else
            cout << "Error: Incorrect house data in file!!\a" << endl;         
    }
    else                                        // if fail was not successful
    {                                           // execute statements in false path
        cout << "File \"bonus.txt\" "
             << "not found."
             << endl;
    }

    system("PAUSE");

    return 0;
}

readHousehold(ifstream &inFile,int idhouseholdArray[], double incomeArray[], int membersArray[],int size)
{
     int count = 0, rtnCode = 0;
     double temp;

     inFile >> temp;
     while ((!inFile.fail()) && (count < size))
     {
        idhouseholdArray[count] = temp;
        count++;
        incomeArray[count] = temp;
        count++;
        membersArray[count] = temp;
        count++;


        inFile >> temp;
        if (count == size)
        {
           if (!inFile.fail()) 
               rtnCode = 1;
        }
     }

     if (count < size)
         rtnCode = 1;

     return rtnCode;
}


void   displayhouseData(int idhouseholdArray[], double incomeArray[], int membersArray[]);
{


}

Get rid of the types in the function call (i.e. int, double). Also get rid of the array brackets. Those go in the function definition, not the function call. Line 33 should look more like this. Note the lack of types and the lack of brackets.

rc = readHousehold(inFile, idhouseholdArray, incomeArray, membersArray, size);

Edited 4 Years Ago by VernonDozier

It is now compliling but it doesnt display the array, did I fill it properly? It gives me a blank

This article has been dead for over six months. Start a new discussion instead.