Please help me correcting my program.The question requires me to offer a repeating MENU with 3 choices.
1. Displays all students
2. choose one by entering the ID and also making changes to it.
3.exit.
My error so far is "cannot convert to `int*' for argument `1' to `in".I don't quite understand what's wrong with the linearSearch line,using it for the first time.
#include <iostream>
#include <string>
using namespace std;
int linearSearch(int [],int,int);
struct theStudent
{
string studentName;
int studentID;
float studentGPA;
} ;
string i;
const int arrSize=2;
int main()
{
theStudent students[arrSize] = {
{"Robert",7,3.2},
{"Sam",6,3.5}
};
int location ,id,index,choice,results;
do
{
cout <<"MENU"<<endl;
cout <<"1.View all students"<<endl;
cout <<"2.Update the list"<< endl;
cout <<"3.Quit"<< endl;
cin >> choice;
switch (choice)
{
case 1:
cout <<"You have these so far:\n";
for( index=0;index <2;index++)
{
cout<<students[index].studentID<<endl;;
cout<<students[index].studentName<<endl;
cout<<students[index].studentGPA<<endl;
}
break;
case 2:
cout <<"Enter ID to change info:\n";
cin >> id;
results=linearSearch(students,arrSize,id);
if(results == -1)
cout<<"Doesn't exist.\n";
else
{
cout<<"That ID is found"<<results;
cout <<"Make changes" <<endl;
cin >> students[index].studentID ;// cin>>students[index].studentID
cout <<"Make changes to name" << endl;
cin >>students[index].studentName;
cout<<"Change the GPA"<<endl;
cin>>students[index].studentGPA;
}
}
}while(choice!=3);
return 0;
}