error

i keep getting this error through my program
error: expected ‘,’ or ‘...’ before numeric constant
the line that is getting this one is
int search (string arr[], int 1001, string name)
it is the function first line.

i also get this error
error: expected primary-expression before ‘]’ token
on both of these lines
mloc= search (mnames[], 1001, name);
floc= search (fnames[], 1001, name);

here is also my whole code if you need it

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

using namespace std;

const int NUM_NAMES = 1000;
void askName (string& name);
int search (string arr[], int 1001, string name);

int main()
{
string mnames[NUM_NAMES], fnames[NUM_NAMES], name;
int mloc, floc;
ifstream input("babynames.txt");
int i = 0;
while (input >> mnames[i] >> fnames[i] && i++ < NUM_NAMES);
for (int i = 0; i < NUM_NAMES; i++)
cout << mnames[i] << "\t\t" << fnames[i] << endl;

askName (name);
mloc= search (mnames[], 1001, name);
floc= search (fnames[], 1001, name);
}

void askName (string& name){
cout << "Enter a name" << endl;
cin >> name;
}

int search (string arr[], int 1001, string name){
int i;
i=0;
if (arr[i]!= name){
while (i < 1001)
i++;
}
return i;
}
Put your code in code brackets so its easier to read.

also, variable "name" is not declared in main and "1001" is not a valid variable name.
Last edited on
ok that solves the first error so how can i solve the error: expected primary-expression before ‘]’ token
on both of these lines
mloc= search (mnames[], size, name);
floc= search (fnames[], size, name);
i changed all of the 1001 and NUM_NAME to size now
Topic archived. No new replies allowed.