-2

Here is the beginning of a program I am writing. As you can see it is incomplete, but I was checking my program for bugs and I got this error. I looked it up and found solutions such as "do not include brackets while calling a multidim array" I corrected and got this error. Any advice on how to solve it?

#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<fstream>

using namespace std;

void readEmployees();
void readPasswords();
void mixPasswords(string(*)[50], string[], string(*)[50]);

string employee[50][50];

string passwords[50];

string passwordsAssigned[50][50];

int main()
{
    readEmployees();
    readPasswords();

    mixPasswords(employee, passwords, passwordsAssigned);

    return 0;
}

void readEmployees()
{
    int y;
    ifstream fileInput;
    fileInput.open("employees.txt");

    for(int x = 0; x < 50; x++)
    {
            fileInput >> employee[x][y] >> employee[y][x];
            y++;
    }



}

void readPasswords()
{
    ifstream fileInput;
    fileInput.open("passwords.txt");

    for(int x = 0; x < 50; x++)
    {
            fileInput >> passwords[x];
    }

}

void mixPasswords(string employee(*)[50], string passwords[], string completed(*)[50])
{

}
hammonak
  • 1
  • 5

1 Answers1

1

Your declaration void mixPasswords(string, string, string); does not match the types of the parameters you are passing to it. You need to change your declaration to something like

void mixPasswords(string[][50], string[], string[][50]);

Additionally, the definition you have for mixPasswords does not define the previously declared function since its parameter list doesn't match the declaration. Instead it declares and defines a new, unused, overload of mixPasswords that takes a different set of parameters. You need to make your declaration and definition match.

Miles Budnek
  • 28,216
  • 2
  • 35
  • 52
  • I have updated my code. I now get an error message as follows: error: expected ‘,’ or ‘...’ before ‘(’ token – hammonak Nov 30 '17 at 23:29
  • That's because `string employee(*)[50]` should be `string (*employee)[50]` Pointers and references to arrays have an (IMO) ugly syntax, which is why I recommended using the `string employee[][50]` syntax for declaring your parameters. That is entirely equivalent to `string (*employee)[50]` in that context. – Miles Budnek Nov 30 '17 at 23:38