i keep getting an error when i try to pass the array through function. Help?

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

using namespace std;

void input(double carSpeed[6][7]);

int main (void)
{   
    double carSpeed[6][7];

    input(carSpeed[][]);


    return 0;
}

void input(double carSpeed[][7])
{
    ifstream FileName;
    FileName.open("noise.txt"); 
    for(int x=0; x<6; x++)
    {
        FileName >> carSpeed[x][0];
        for(int y = 1; y < 8 ; y++)
        {
            FileName >> carSpeed[x][y];
        }
    }
    FileName.close();

    return;
}

Change to this input(carSpeed); Also use code tags.

Always believe that it's better to make the COLS a const.

const int COLS = 7;

In the prototype and function header just do as follows.

void input(double carSpeed[][COLS]);

// ...

void input(double carSpeed[][COLS])
{
ifstream FileName;
FileName.open("noise.txt"); 
for(int x=0; x<6; x++)
{
FileName >> carSpeed[x][0];
for(int y = 1; y < 8 ; y++)
{
FileName >> carSpeed[x][y];
}
}
FileName.close();

return;
}
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.