Add search functionality to your program according to the user inputs. Use switch-case to deal with different user inputs

Having trouble with searching in my program.
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
#include <iomanip>

using namespace std;

struct Employee{
char empCode;
string SSN;
string firstN;
string lastN;
string depName;
string role;
double salary;
};

void bySSN();
void secOps();
void devOps();
ifstream inFile("employee.txt");

int main(){
string data;
const int N = 23;
Employee stuff[N];
int choice;

if (!inFile){
cout << "File can't be opened! " << endl;
exit(0);
}

for(int i = 0; i < N; i++){
inFile >> stuff[i].empCode >> stuff[i].SSN
>> stuff[i].firstN >> stuff[i].lastN >> stuff[i].depName
>> stuff[i].role >> stuff[i].salary;
}

cout<< "The size of employees is "<< N<< endl<< endl;

for(int i = 0; i < N; i++){
cout<< stuff[i].empCode << setw(15);
cout<< stuff[i].SSN << setw(10);
cout<< stuff[i].firstN << setw(10);
cout<< stuff[i].lastN << setw(20);
cout<< stuff[i].depName << setw(20);
cout<< stuff[i].role << setw(10);
cout<< stuff[i].salary << endl;
}

while(choice != 4){
cout<< endl;
cout<< "-------- Search Menu ----------"<< endl;
cout<< "1. Search an employee by SSN"<< endl;
cout<< "2. View only SecOps team"<< endl;
cout<< "3. View only DecOps developers"<< endl;
cout<< "4. Exit"<< endl;
cout<< "-------------------------------"<< endl;

cout<< "Enter a number to select what you want: ";
cin>> choice;

switch(choice){
case 1:
bySSN();
break;
case 2:
secOps();
break;
case 3:
devOps();
break;
default:
break;
}
cout<< endl;
}
}

void bySSN(){
const int N = 23;
string SSNnum;

cout<< "Enter employee's social security number: ";
cin>> SSNnum;
cout<< endl;

for(int i = 0; i < N; i++){
if(SSNnum == stuff[i]){
cout<< stuff[i].empCode << setw(15);
cout<< stuff[i].SSN << setw(10);
cout<< stuff[i].firstN << setw(10);
cout<< stuff[i].lastN << setw(20);
cout<< stuff[i].depName << setw(20);
cout<< stuff[i].role << setw(10);
cout<< stuff[i].salary << endl;
} else {
cout<< "Couldn't find employee";
}
}
}

void secOps(){
cout<< "Success2";
}

void devOps(){
cout<< "Success3";
}
use code tags
Topic archived. No new replies allowed.