Hey guys im new to C++ so if this is an dumb question all apologies. Whats going on is i am comparing a user entered major with one from a structure of information on students (name,hours,gpa,etc..). for this im trying to pull out majors in example say someone was a ENG major then it would pull out those students and print some of there cudentials.

Anyways im getting an error of
" cannot convert StudentRecord' to `const char*' for argument `2' to `int strcmp(const char*, const char*)' "
for these two lines
if(strcmp( student.major, studentmajorIn)!=0)
if(strcmp( student.major, studentmajorIn)==0)

any help is very appreciated.

void option5(StudentRecord student[],int n)
{
 double grade;
 char majorIn[5];
 int i;
cout<<"Enter desired major"<<endl;
cin.getline(majorIn,5);
cout<<"enter desired GPA"<<endl;
cin>>grade;


cout<<"Last Name       "<<"First Name      "<<"Hometown         "<<"GPA"<<endl<<endl;

if(strcmp( student[i].major,student[i]majorIn)!=0)
cout<<"No Matches found"<<endl;


for(i=0;i<=n-1;i++)
{
if(strcmp( student[i].major, student[i]majorIn)==0)
   if(student[i].gpa>=grade)
cout<<left<<setw(16)<<student[i].lastName<<setw(16)<<student[i].firstName<<setw(16)<<student[i].hometown<<setw(4)<<right<<student[i].gpa<<endl;

The lack of a . between student and majorIn is fatal.

The only problem is that theres no majorIn in the structure to begin with if i add it will the structure receive that data and then use it to compare?

also if theres a compare function that is not case sensitive since the (toupper) function wont compile right for me

1. If no majorIn member in a structure, why you wrote senseless and invalid expression student[i]majorIn ? It's simple majorIn argument!
2. What for you wrote the 1st if statement? You don't initialize i at that moment but refer to student[i] ...
3. Why so strange form for(i=0;i<=n-1;i++) ? Keep it simpler: for (i=0; i < n; i++) . Think: it's the same condition!
4. There is case-insensitive non-standard C-string compare function stricmp in some C++ implementations. But it's not so hard to make your own function using toupper. What's a problem?
5. Think about input error handling. Suppose the user types not-a-number instead grade value. Now you can't detect this case.

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.