How to fix this error

I keep getting the following error:
"cannot convert 'std::string' to 'int' for argument '1' to 'int linearSearch(int, int*, int)'".

Basically my main arrays consists of:
string studentID[] = {"P1001", P"1002"}
int studentMark[] = {78.50, 66}

I am trying to allow the user to search for a given studentID, and the output will display the correponding marks for it. I am trying to use linear search (not sure if Im doing it right or not)

My coding looks like this at the moment:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include <iostream>
#include <string>
using namespace std;

int linearSearch(int, int [], int);

int main()
{
    int menu;
    string studentID[] = {"P1001", "P1002"};
    float studentMark[] = {78.50, 66};
    int totalStudents=0;
    float totalMarks=0;
    float averageMark;
    string id;
    int mark;
    char studentGrade;
    int j;
    int i=linearSearch(id,studentMark,2);
  
    cout << "MAIN MENU\n"
         << "0. Exit         1. Statistics\n"
         << "2. Enter mark   3. Find mark\n"
         << "------------------------------\n"
         << "Your choice -> ";
    cin >> menu;
  while (menu != 0)
  {
    switch (menu)
    {
           case 1:
                for(int j=0;j<2;j++)
                 {
                   totalMarks+=studentMark[j];
                   totalStudents++;
                 }
                 averageMark=totalMarks/totalStudents;
                 cout << "Number of records: " << totalStudents <<endl;
                 cout << "Mean or average: " << averageMark <<endl;
                break;
           case 2:
                cout << "Enter a Student Record: " <<endl;
                cout << "Student ID -> ";
                cin >> id;
                break;
           case 3:
                cout << "Find marks for ID -> " << endl;
                cin >> id;
                
                else
                   cout << "Student Record does not exist";
                break;
           default:
                   cout << "Invalid selection. Please make a selection between 0-3.\n"
                        << endl;
                   break;
    }    
system("Pause");
    cout << "MAIN MENU\n"
         << "0. Exit         1. Statistics\n"
         << "2. Enter mark   3. Find mark\n"
         << "----------------------------\n"
         << "Your choice -> ";
    cin >> menu;
  }
  
return 0;
}


How can I fix the error?
the error says it all.

Your function takes 'int's, and you're giving it strings and floats. Strings and floats are not ints, and therefore you're getting errors. Either change the function to take strings and floats, or convert your strings and floats to ints. It's hard to say which approach is preferable without seeing the function in question -- but I'd guess the former.
Topic archived. No new replies allowed.