ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
if i only enter 1 set of records i get a correct return but if i enter more than one set of record it only reconizes the last set. so when i search for student id the only one thats in the file that works correctly and displays the correct output is the last studentid entered rest dont work properly
Code:
oid loadarray() {
fin.open("E:\\studentidarray.txt");
string word;
vector<string> myWords;
while (fin >> word)
{
myWords.push_back(word);
}
fin.close();
}
void search_data()
{
match = 'N';
row = 0;
maxsize = 8;
cout << " enter a student id to be searched: ";
cin >> students;
while (match == 'N' && row < maxsize)
{
if (students == studentid)
{
match = 'Y';
}
else
{
row = row + 1;
}
if (match == 'Y')
{
sucessful();
}
else
{
unsucessful();
}
}
cout << " Another Search? ";
cin >> moresearch;
moresearch = toupper(moresearch);
while (moresearch != 'Y' && moresearch != 'N')
{
cout << " Error ";
cout << " Please enter Y or N as a response ";
cin >> moresearch;
moresearch = toupper(moresearch);
}
if (moresearch == 'Y')
{
search_data();
}
}
void sucessful()
{
cout << "student was found!" << endl << endl;
if (gpa >= 3.65)
{
cout << firstname << " " << lastname << " " << "is on the Dean's List." << endl;
}
if(gpa >= 2.0 || gpa < 3.65)
{
cout << firstname << " " << lastname << " " << "is an average student." << endl;
}
if (gpa < 2.0)
{
cout << firstname << " " << lastname << " " << "is on Academic Probation." << endl;
}
}
void unsucessful()
{
cout << "Student ID was not found" << endl;
;
}
Last edited by ekincaid2002; 03-19-2016 at 03:44 PM.
in otherwords seems like its not starting at the first line each search feel like its starting at the last line and acting like the rest are invalid because its starting at the end line.
Last edited by ekincaid2002; 03-19-2016 at 04:18 PM.
Your original search data function does not use the student array file. It only uses the values of the last entered student from your build function. Since Each student's data is a single string you need to parse it to separate the values.
how do i do that and have all 4 elements still be linked as one entry? like i have to run a search on the id and the output that is displayed is based on the gpa of that student id. just realised i have 2 search data in here the one with match is the correct one im using.
Last edited by ekincaid2002; 03-20-2016 at 10:24 AM.
array [] we have learned but i'm not good with that and don't really understand it well. should studentid be implemented like studentid[] ? and if i do it that way will the other elements still be able to be referenced by the id?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.