I showed you the for loop because it actually makes code look a lot nicer than an alternative. I can't even begin to imagine what this code would look like without loops, but with labels instead:
1 2 3 4 5 6 7 8 9 10 11 12
|
do {
std::cout << "\nPlease enter a name to search for: ";
getline(std::cin, strSearch);
// Search mMembersList
for (auto member : mMembersList)
// If a member matched the search
if (boost::algorithm::icontains(member.first, strSearch))
// Make sure member doesn't exist in mPersonalResults
if (mPersonalResults.find(member.first) == mPersonalResults.end())
// Add unused members to vFoundNames
vFoundNames.push_back(member.first);
} while (!vFoundNames.size());
|
From what I understand about your knowledge on C++, you won't be able to do that. That was just pulled out of a small program I'm helping someone with and learning myself. I'm trying to help you understand why what you're doing is bad/wrong, as everyone else that posted here. There is nothing wrong with focusing on high school, knowledge is power my man, but I don't see that writing two completely different games with over 1K lines of code was worth not learning more essentials.
My point being, grab a book, google a good tutorial, or learn from someone that has experience. Try to lose all of the bad habits, starting with your attitude, and try to relearn the language. This stuff isn't easy, by any means, but it doesn't mean you need to get cocky or arrogant about it, but take every suggestion with a grain of salt. I've been bashed from doing things in my programs that are bad practice, and I've since moved away from doing so. I wasn't willing to give up what I knew and liked and felt comfortable with, but after thinking about it, weighing out the pros and cons, I decided to start trying it out, and I've since changed a lot of bad habits in my code.
I hope you stick with C++, but please, lighten up man.