0

One side note, when I was writing the test app, I had to set Num_Students after I read from the input file. My read from the input file looks like the following: (there is some debug still so I can see that it is doing something)

printf("main: reading grades.txt\n");
	ifstream infile("grades.txt");
	if (!infile.is_open())
		printf("main: Failed to open grades.txt\n");
	else{
		while(!infile.eof() && i < Num_grades){
			infile >> grades[i].ID;
			infile >> grades[i].q1;
			infile >> grades[i].q2;
			infile >> grades[i].e1;
			infile >> grades[i].e2;
			infile >> grades[i].assg1;
			infile >> grades[i].assg2;
			infile >> grades[i].assg3;
			if (! infile.eof()){
				cout << "main: grades[" << i << "].ID=" << grades[i].ID << endl;
				i++;
			}
		}
	}
	infile.close();
	Num_Students = i;

Please make any changes from the above that make sense to you.

We need to get your code compiled and running. If you want to work on it some, go ahead. When I first started working with your file, I commented out anything that had a compile error that I couldn't "just fix". Then I started running it and got the functionality that was implemented working. Then I started adding the functionality that I had commented out. (Its an iterative approach to development.)

If you get stuck:
Compile your file.
Post the entire file you just compiled in code=c++ tags
Post the entire error list from that compile in code tags

0

Here is the code and errors in code tags:

#include<iostream>
#include<fstream>
using namespace std;
//Struct students defines each element in the array.
struct students{
       int ID;
       int q1;
       int q2;
       int e1;
       int e2;
       int assg1;
       int assg2;
       int assg3;
       };
//searchList will search inside of the infile for a specific ID of a student and output all of their grades.
int searchList(students grades[], int Num_Students, int ID){
                    int index = 0;
                    bool found =false;
                    while (index < Num_Students && !found){
                          if (grades[index].ID == ID){
                                            found = true;
                                            cout << grades[index].q1;
                                            cout << grades[index].q2;
                                            cout << grades[index].e1;
                                            cout << grades[index].e2;
                                            cout << grades[index].assg1;
                                            cout << grades[index].assg2;
                                            cout << grades[index].assg3;
                                            break;
                          }
                          index++;
                    }
                    if( found )
                           return index;
                    else
                            return -1;
}
//searchList2 will also find the student with a specific ID and output the projected letter grade for that student.
int searchList2(students grades[], int Num_Students, int ID){
    int LAB =15;
    int index = 0;
    bool found = false;
    double total = 0;
    while (index < Num_Students && !found){
          if (grades[index].ID == ID){
                               found = true;
                               total = (grades[index].q1+grades[index].q2
                               +grades[index].e1+grades[index].e2+grades[index].assg1+
                               grades[index].assg2+grades[index].assg3)*0.1 + ((grades[index].e1+grades[index].e2)/2)*.15 + LAB;
                             }
                             index++;
                           }
                           if( found ){
                               if (total < 60)
                                              cout << "You have an F" << endl;
                                              else if(total <69)
                                              cout << " You have a D" << endl;
                                              else if(total < 79)
                                              cout << "You have a C" << endl;
                                              else if(total < 89)
                                              cout << "You have a B" << endl;
                                              else if( total <= 100)
                                              cout << "You have an A" << endl;
                                              return 1;
                                              }
                                          else
                                            return -1;
}
//showList will output the grades in order to the screen.
void showList(int grades[], int num){
     for(int m = 0; m < num; m++)
             cout << grades[m] << " ";
     cout << endl;
}
//sortList is a bubble sort that will sort through a specific field and put into order.
void sortList( students grades[], int num, string sortThis){
     bool swap;
     int temp;
     int Num_Students = 65;
     do{
         swap = false;
         for(int k = 0; k < (num - 1); k++){
                 if(grades[k].ID > grades[k + 1].ID){
                              temp = grades[k].ID;
                              grades[k] = grades[k + 1];
                              grades[k +1].ID = temp;
                              swap = true;

                 }
         }
     }while (swap);
}

                
int main(){
    
    int ID;
    char command;
    int Num_grades = 65;
//grades[] is the array.
    students grades[Num_grades];
    int i =0;
    int Num_Students;
    string sortList;
    ifstream infile;
    int sortThis;
    infile.open("grades.txt");
    
    while(!infile.eof()){
                infile >> grades[i].ID;
                infile >> grades[i].q1;
                infile >> grades[i].q2;
                infile >> grades[i].e1;
                infile >> grades[i].e2;
                infile >> grades[i].assg1;
                infile >> grades[i].assg2;
                infile >> grades[i].assg3;
                i++;
    }
//Outfile to display all grades.
    ofstream outfile;
    outfile.open("report.txt");
    
    bool exit = false;
//do-while Menu.
    do{
         cout << "1: Publish grade report" << endl;
         cout << "2: Search for student grade by ID" << endl;
         cout << "3: Sort grades" << endl;
         cout << "4: Projected grade" << endl;
         cout << "5: Distribute grades" << endl;
         cout << endl;
         cout << "Enter an operator: ";
         cin >> command;
         
         switch (command) {
//Publish grades to "report.txt"
           case 1:
                for(int j = 0; j<0;j++){
                        outfile << grades[j].ID;
                        j++; 
                }
           break;
//Search for a students grade by ID and output all of their grades.
           case 2:
                cout << "Enter an ID" << endl;
                cin >> ID;
                if( searchList( grades, Num_Students, ID ) == -1);
                cout << "Student not found!" << endl; 
                break;
//Sort IDs or grades into a column.
           case 3:
                do{
                    char sortWhat;
                   cout << "1: Student ID" << endl;
                   cout << "2: Quiz 1 Grade" << endl;
                   cout << "3: Quiz 2 Grade" << endl;
                   cout << "4: Exam 1 Grade" << endl;
                   cout << "5: Exam 2 Grade" << endl;
                   cout << "6: Assignment 1 Grade" << endl;
                   cout << "7: Assignment 2 Grade" << endl;
                   cout << "8: Assignment 3 Grade" << endl;
                   cout << endl;
                   cout << "Enter field to be sorted(0-7): ";
                   cin >> sortWhat;
                   int scores[Num_grades];
                   
                   switch (sortWhat){ 
                          case 1:
                               Num_Students = i;
                               for (int ii =0; ii < Num_Students; i++)
                                    scores[ii] = grades[ii].ID
                               sortList(scores, Num_Students);
                               showList(scores, Num_Students)
                               break;
                          case 2:
                               for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].q1
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          case 3:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].q2
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          case 4:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].e1
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          case 5:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].e2
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          case 6:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].assg1
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          case 7:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].assg2
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          case 8:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].assg3
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students)
                               break;
                          default:
                                  cout << "Invalid Command" << endl;
                   }
                }while( !exit ); 
                break;
//Project the letter grade of a specific student by ID.
           case '4':
                cout << "Enter an ID" << endl;
                cin >> ID;
                if( searchList2(grades, Num_Students, ID) == -1 )
                  cout << "Student not found!" << endl;
                break;
//Distribute all of the letter grades of all of the students.
           case '5':
                break;     
           default:
                 exit = true;
           }
    }while( !exit );                                   
    
    infile.close();
    system("PAUSE");
    return 0;
}
In function `int main()':
 error: expected `;' before "sortList"
error: expected `;' before "break"
error: `NumStudents' undeclared (first use this function)
error: (Each undeclared identifier is reported only once for each function it appears in.)
error: expected `;' before "sortList"
error: expected `;' before "break"
"                                                   "
etc. with last two errors

Hope this helps.
:sad: :confused:

1
case 1:
                               Num_Students = i;
                               for (int ii =0; ii < Num_Students; i++)
                                    scores[ii] = grades[ii].ID
                               sortList(scores, Num_Students);
                               showList(scores, Num_Students)
                               break;

scores[ii] = grades[ii].ID
should have a ;

showList(scores, Num_Students)
should have a ;

Votes + Comments
not that you need my rep post, but thanks for helping with his problem.
0

ddanbe I tried what you suggested here is the new code with errors:

#include<iostream>
#include<fstream>
using namespace std;
//Struct students defines each element in the array.
struct students{
       int ID;
       int q1;
       int q2;
       int e1;
       int e2;
       int assg1;
       int assg2;
       int assg3;
       };
//searchList will search inside of the infile for a specific ID of a student and output all of their grades.
int searchList(students grades[], int Num_Students, int ID){
                    int index = 0;
                    bool found =false;
                    while (index < Num_Students && !found){
                          if (grades[index].ID == ID){
                                            found = true;
                                            cout << grades[index].q1;
                                            cout << grades[index].q2;
                                            cout << grades[index].e1;
                                            cout << grades[index].e2;
                                            cout << grades[index].assg1;
                                            cout << grades[index].assg2;
                                            cout << grades[index].assg3;
                                            break;
                          }
                          index++;
                    }
                    if( found )
                           return index;
                    else
                            return -1;
}
//searchList2 will also find the student with a specific ID and output the projected letter grade for that student.
int searchList2(students grades[], int Num_Students, int ID){
    int LAB =15;
    int index = 0;
    bool found = false;
    double total = 0;
    while (index < Num_Students && !found){
          if (grades[index].ID == ID){
                               found = true;
                               total = (grades[index].q1+grades[index].q2
                               +grades[index].e1+grades[index].e2+grades[index].assg1+
                               grades[index].assg2+grades[index].assg3)*0.1 + ((grades[index].e1+grades[index].e2)/2)*.15 + LAB;
                             }
                             index++;
                           }
                           if( found ){
                               if (total < 60)
                                              cout << "You have an F" << endl;
                                              else if(total <69)
                                              cout << " You have a D" << endl;
                                              else if(total < 79)
                                              cout << "You have a C" << endl;
                                              else if(total < 89)
                                              cout << "You have a B" << endl;
                                              else if( total <= 100)
                                              cout << "You have an A" << endl;
                                              return 1;
                                              }
                                          else
                                            return -1;
}
//showList will output the grades in order to the screen.
void showList(int grades[], int num){
     for(int m = 0; m < num; m++)
             cout << grades[m] << " ";
     cout << endl;
}
//sortList is a bubble sort that will sort through a specific field and put into order.
void sortList( students grades[], int num, string sortThis){
     bool swap;
     int temp;
     int Num_Students = 65;
     do{
         swap = false;
         for(int k = 0; k < (num - 1); k++){
                 if(grades[k].ID > grades[k + 1].ID){
                              temp = grades[k].ID;
                              grades[k] = grades[k + 1];
                              grades[k +1].ID = temp;
                              swap = true;

                 }
         }
     }while (swap);
}

                
int main(){
    
    int ID;
    char command;
    int Num_grades = 65;
//grades[] is the array.
    students grades[Num_grades];
    int i =0;
    int Num_Students;
    string sortList;
    ifstream infile;
    int sortThis;
    infile.open("grades.txt");
    
    while(!infile.eof()){
                infile >> grades[i].ID;
                infile >> grades[i].q1;
                infile >> grades[i].q2;
                infile >> grades[i].e1;
                infile >> grades[i].e2;
                infile >> grades[i].assg1;
                infile >> grades[i].assg2;
                infile >> grades[i].assg3;
                i++;
    }
//Outfile to display all grades.
    ofstream outfile;
    outfile.open("report.txt");
    
    bool exit = false;
//do-while Menu.
    do{
         cout << "1: Publish grade report" << endl;
         cout << "2: Search for student grade by ID" << endl;
         cout << "3: Sort grades" << endl;
         cout << "4: Projected grade" << endl;
         cout << "5: Distribute grades" << endl;
         cout << endl;
         cout << "Enter an operator: ";
         cin >> command;
         
         switch (command) {
//Publish grades to "report.txt"
           case 1:
                for(int j = 0; j<0;j++){
                        outfile << grades[j].ID;
                        j++; 
                }
           break;
//Search for a students grade by ID and output all of their grades.
           case 2:
                cout << "Enter an ID" << endl;
                cin >> ID;
                if( searchList( grades, Num_Students, ID ) == -1);
                cout << "Student not found!" << endl; 
                break;
//Sort IDs or grades into a column.
           case 3:
                do{
                    char sortWhat;
                   cout << "1: Student ID" << endl;
                   cout << "2: Quiz 1 Grade" << endl;
                   cout << "3: Quiz 2 Grade" << endl;
                   cout << "4: Exam 1 Grade" << endl;
                   cout << "5: Exam 2 Grade" << endl;
                   cout << "6: Assignment 1 Grade" << endl;
                   cout << "7: Assignment 2 Grade" << endl;
                   cout << "8: Assignment 3 Grade" << endl;
                   cout << endl;
                   cout << "Enter field to be sorted(0-7): ";
                   cin >> sortWhat;
                   int scores[Num_grades];
                   
                   switch (sortWhat){ 
                          case 1:
                               Num_Students = i;
                               for (int ii =0; ii < Num_Students; i++)
                                    scores[ii] = grades[ii].ID;
                               sortList(scores, Num_Students);
                               showList(scores, Num_Students);
                               break;
                          case 2:
                               for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].q1;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          case 3:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].q2;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          case 4:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].e1;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          case 5:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].e2;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          case 6:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].assg1;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          case 7:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].assg2;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          case 8:
                                  for (int ii =0; ii < NumStudents; i++)
                                    scores[ii] = grades[ii].assg3;
                               sortList( scores, Num_Students);
                               showList( scores, Num_Students);
                               break;
                          default:
                                  cout << "Invalid Command" << endl;
                   }
                }while( !exit ); 
                break;
//Project the letter grade of a specific student by ID.
           case '4':
                cout << "Enter an ID" << endl;
                cin >> ID;
                if( searchList2(grades, Num_Students, ID) == -1 )
                  cout << "Student not found!" << endl;
                break;
//Distribute all of the letter grades of all of the students.
           case '5':
                break;     
           default:
                 exit = true;
           }
    }while( !exit );                                   
    
    infile.close();
    system("PAUSE");
    return 0;
}
In function `int main()':
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
error: `NumStudents' undeclared (first use this function)
error: (Each undeclared identifier is reported only once for each function it appears in.)
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
 error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
error: no match for call to `(std::string) (int[((unsigned int)((int)Num_grades))], int&)'
0

i need some help here....i am taking input as name and i want to count the alphabets in the string as integers....e.g. if the in out is cab i have to output 3+1+2 = 5 i have been able to ad d up the strings..but if my input starts with a " " (space) it does not wrk...please help

<code>
n = toLowerCase(n);


for(int i = 0 ; i<n.length() ; i++)
{
lower = lower + n.at(i);
}
for(int k=0;k<n.length();k++)
{


index=index+int(n.at(k)-96);
cout<<index<<endl;
//just to see adding
}



while(index>=10)
{
temp=temp+index%10;
index=index/10;


s2=sum=temp+index;
}
sum=sum%10;
s2=s2/10;
a=sum+s2;
cout<<a<<endl;
if(a==1)
cout<<"1you are quirky and eccentric"<<endl;
else if(a==2)
cout<<"2you are introvert and shy"<<endl;
else if(a==3)
cout<<"3you are party animal"<<endl;
else if(a==4)
cout<<"4you are trustworthy and reliable"<<endl;
else if(a==5)
cout<<"5you are patient and forgiving"<<endl;
else if(a==6)
cout<<"6you are friendly and jovial"<<endl;
else if(a==7)
cout<<"7you are lucky and talented"<<endl;
else if(a==8)
cout<<"8you are genius"<<endl;
else if(a==9)
cout<<"9you are street-smart and cunning"<<endl;
else


</code>

Edited by happygeek: fixed formatting

0

@singhraghav
1) Don't Hijack threads - Start your own (we much much prefer it)
2) After 13 posts you are expect to now how to use code tags
(read this)

Follow that advise and you will get some help.

Thanks,
Chris

0

You have a string variable declared as sortList and a method declared as sortList.
Decide what you want, there are systems who can detect this before you even compile things.

0

Hey, I actually figured out how to do the "sortList"t function. Sorry, to go though all the trouble of figuring out how to fix that messed up sortList function I had to rewrite it because it was causing to many problems. OK, this is the last problem I have with the program. This is the new program:

#include<iostream>
#include<fstream>
using namespace std;
//Struct students defines each element in the array.
struct students{
       int ID;
       int q1;
       int q2;
       int e1;
       int e2;
       int assg1;
       int assg2;
       int assg3;
       };
//searchList will search inside of the infile for a specific ID of a student and output all of their grades.
int searchList(students grades[], int Num_Students, int ID){
                    int index = 0;
                    bool found =false;
                    while (index < Num_Students && !found){
                          if (grades[index].ID == ID){
                                            found = true;
                                            cout << grades[index].q1;
                                            cout << grades[index].q2;
                                            cout << grades[index].e1;
                                            cout << grades[index].e2;
                                            cout << grades[index].assg1;
                                            cout << grades[index].assg2;
                                            cout << grades[index].assg3;
                                            break;
                          }
                          index++;
                    }
                    if( found )
                           return index;
                    else
                            return -1;
}
//searchList2 will also find the student with a specific ID and output the projected letter grade for that student.
int searchList2(students grades[], int Num_Students, int ID){
    int LAB =15;
    int index = 0;
    bool found = false;
    double total = 0;
    while (index < Num_Students && !found){
          if (grades[index].ID == ID){
                               found = true;
                               total = (grades[index].q1+grades[index].q2
                               +grades[index].e1+grades[index].e2+grades[index].assg1+
                               grades[index].assg2+grades[index].assg3)*0.1 + ((grades[index].e1+grades[index].e2)/2)*.15 + LAB;
                             }
                             index++;
                           }
                           if( found ){
                               if (total < 60)
                                              cout << "You have an F" << endl;
                                              else if(total <69)
                                              cout << " You have a D" << endl;
                                              else if(total < 79)
                                              cout << "You have a C" << endl;
                                              else if(total < 89)
                                              cout << "You have a B" << endl;
                                              else if( total <= 100)
                                              cout << "You have an A" << endl;
                                              return 1;
                                              }
                                          else
                                            return -1;
}
//showList will output the grades in order to the screen.
void showList(int grades[], int num){
     for(int m = 0; m < num; m++)
             cout << grades[m] << " ";
     cout << endl;
}
//sortList is a bubble sort that will sort through a specific field and put into order.
void sortList( students grades[], int size){
     bool swap = 1;
     int choose;
     students temp;
     
     cout << "Sort by What: 1. Student ID\n"
          << " 2. Quiz 1\n"
          << " 3. Quiz 2\n"
          << " 4. Exam 1\n"
          << " 5. Exam 2\n"
          << " 6. Assg 1\n"
          << " 7. Assg 2\n"
          << " 8. Assg 3\n"
          << "Select Choice: ";
     cin >> choose;
     while (swap) {
           swap = 0;
           for(int i =0; i < size-1; i++) {
                   switch(choose) {
                                  case 1:
                                       if(grades[i].ID > grades[i+1].ID){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 2:
                                       if(grades[i].q1 > grades[i+1].q1){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 3:
                                       if(grades[i].q2 > grades[i+1].q2){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 4:
                                       if(grades[i].e1 > grades[i+1].e1){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 5:
                                       if(grades[i].e2 > grades[i+1].e2){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 6:
                                       if(grades[i].assg1 > grades[i+1].assg1){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 7:
                                       if(grades[i].assg2 > grades[i+1].assg2){
                                                       swap = 1;
                                                       }
                                                       break;
                                  case 8:
                                       if(grades[i].assg3 > grades[i+1].assg3){
                                                       swap = 1;
                                                       }
                                                       break;
                   }
                   if(swap) {
                     temp = grades[i];
                     grades[i] = grades[i+1];
                     grades[i+1] = temp;
                     }
           }
}
}
                                                                   
int main(){
    
    int ID;
    char command;
    int Num_grades = 65;
//grades[] is the array.
    students grades[Num_grades];
    int i =0;
    int Num_Students;
    string sortList;
    ifstream infile;
    infile.open("grades.txt");
    
    while(!infile.eof()){
                infile >> grades[i].ID;
                infile >> grades[i].q1;
                infile >> grades[i].q2;
                infile >> grades[i].e1;
                infile >> grades[i].e2;
                infile >> grades[i].assg1;
                infile >> grades[i].assg2;
                infile >> grades[i].assg3;
                i++;
    }
//Outfile to display all grades.
    ofstream outfile;
    outfile.open("report.txt");
    
    bool exit = false;
//do-while Menu.
    do{
         cout << "1: Publish grade report" << endl;
         cout << "2: Search for student grade by ID" << endl;
         cout << "3: Sort grades" << endl;
         cout << "4: Projected grade" << endl;
         cout << "5: Distribute grades" << endl;
         cout << endl;
         cout << "Enter an operator: ";
         cin >> command;
         
         switch (command) {
//Publish grades to "report.txt"
           case 1:
                for(int j = 0; j<0;j++){
                        outfile << grades[j].ID;
                        j++; 
                }
           break;
//Search for a students grade by ID and output all of their grades.
           case 2:
                cout << "Enter an ID" << endl;
                cin >> ID;
                if( searchList( grades, Num_Students, ID ) == -1);
                cout << "Student not found!" << endl; 
                break;
//Sort IDs or grades into a column.
           case 3:
                sortList(grades, int size); 
                break;
//Project the letter grade of a specific student by ID.
           case '4':
                cout << "Enter an ID" << endl;
                cin >> ID;
                if( searchList2(grades, Num_Students, ID) == -1 )
                  cout << "Student not found!" << endl;
                break;
//Distribute all of the letter grades of all of the students.
           case '5':
                break;     
           default:
                 exit = true;
           }
    }while( !exit );                                   
    
    infile.close();
    system("PAUSE");

This is the error:`int main()':
error: expected primary-expression before "int"

The error is in the call to "sortList" in case 3. I tried removing the semicolon, int variable, and calling it like this "sortList(students grades, int size) it doesn't compile. Yet, I think it's something pretty simple. :icon_wink:

0

You still have string sortList; in main() and it is masking the function you want to call.

You need to pass the number of students to sortlist
Change the call sortList(grades, int size); into sortList(grades, Num_Students);

0

Unless you've changed the code more than outlined...it compiles, but doesn't necessarily work.

Make sure you test it to ensure that it does what it is supposed to.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.