I am trying to go threw a vector of Student objects. If I find a matching ID to the one I am searching for it will display their info.
However, when I try to find a specific ID .compare isn't seeing a match even though it should.
My output: first line is the ID I am looking for, second is the current ID being looked at, then is the result of the compare.
a11111111
a22222222
-1
no match
a11111111
a11111111
-1
no match
Asked for more of the code so here is the entire program: (issue in displayID)
header file
#ifndef structures_h
    #define structures_h
    #include <vector>
    #include <iostream>
    #include <stdlib.h> 
    #include <stdio.h>
    #include <fstream>
    #include <sstream>
    #include <string>
    #include <algorithm>
    #include <stdio.h>
    #include <map>
    using namespace std;
main program
#endif
typedef pair<string, string> Name; // first name, last name
typedef map<string, int> Grades; // map courses to scores
#include "struct.h"
class Student {
    public:
        void display(ostream& os) const;
        void setId(string);
        void setName(string, string);
        void setGrades(string, int);
        string getId();
        string getName();
        void getGrades();
        bool operator<(const Student &rhs) const { return id_ < rhs.id_; }
    private:
        string id_; // e.g. "a22222222"
        Name name_; // e.g. {"ned", "flanders"}
        Grades grades_;
};
void Student::setId(string id) {
    id_ = id;
}
string Student::getId() {
    return id_;
}
void Student::setName(string first, string last) {
    name_ = pair<string,string>(first, last);
}
string Student::getName() {
    return get<0>(name_) + ' ' + get<1>(name_);
}
void Student::setGrades(string course, int score) {
    grades_.insert(make_pair(course, score));
}
void Student::getGrades() {
    for(auto it = grades_.begin(); it != grades_.end(); ++it) {
        cout << it -> first << ' ' <<  it -> second << endl;
    }
}
vector<Student> addStudent(int count, int x, vector<Student>& vStu, string file) {
    string line, first, last;
    ifstream infile(file);
    while (getline(infile, line)) {
        vStu.push_back(Student());
        vStu[count].setId(line);
        getline(infile, line);
        istringstream iss(line);
        if (!(iss >> first >> last)) {
            cout << "failed to get name" << endl;
            break;
        }
        vStu[count].setName(first, last);
        getline(infile, line);
        istringstream iss2(line);
        if (!(iss2 >> x)) {
            cout << "failed to get class number" << endl;
            break;
        }
        for (int i = 0; i < x; i++) {
            string sClass;
            int grade;
            getline(infile, line);
            istringstream iss3(line);
            if (!(iss3 >> sClass >> grade)) {
                cout << "failed to get class and grade" << endl;
                break;
            }
            vStu[count].setGrades(sClass, grade);
        }
        count++;
    }
    return vStu;
}
void display(vector<Student>& vStu) {
    sort(vStu.begin(), vStu.end());
    cout << endl;
    int count = vStu.size();
    for (int i = 0; i<count;i++) {
        cout << vStu[i].getId() << endl;
        cout << vStu[i].getName() << endl;
        vStu[i].getGrades();
        cout << endl;
    }   
}
void displayID(vector<Student>& vStu, string ID) {
    int count = vStu.size();
    string test;
    ID = "a11111111";
    for (int i = 0; i<count;i++) {
        cout<< endl;
        test = vStu[i].getId();
        cout << ID << endl;
        cout << test << endl;
        cout << ID.compare(test) << endl;
        if (ID.compare(test) == 0) {
            cout << "match" << endl;
            cout << vStu[i].getId() << endl;
            cout << vStu[i].getName() << endl;
            vStu[i].getGrades();
            cout << endl;
        } else {
            cout << "no match" << endl;
        }
    }   
    cout << endl;
}
void mainMenu(vector<Student>& vStu) {
    string input;
    string word;
    vector<string> com;
    while(1) {
        cout << "Enter command: ";
        getline(cin,input);
        istringstream iss(input);
        while(iss >> word) {
            com.push_back(word);
        }
        for (int i = 0; i < (int)com.size(); i++) {
            transform(com[i].begin(), com[i].end(), com[i].begin(), ::tolower);
            if (com[i] == "show") {
                display(vStu);
            } else if (com[i] == "showid") {
                displayID(vStu, "a11111111");
            }
        }
    com.clear();
    }
}
int main(int argc, char *argv[]) {
    vector<Student> vStu;
    int count = 0, x = 0;
    if (argc != 2) {
        cout << "Incorrectly called" << endl;
        cout << "    "  << argv[0] << ' ' << "<filename>" << endl; 
        return 1;
    }
    addStudent(count, x, vStu, argv[1]);
    mainMenu(vStu);
}
 
     
    