![]() |
[c++] Address Book
I'm trying to create a fairly simple address book, and everything works until I try to search for a contact in my address book. I decided not to code inputing the address and telephone number until I have the program working properly.
When I select the option to find contacts, something weird happens. For instance, if 1 record has john doe, and another has jane doe, and I try to find all people w/ last name doe, what prints out is: doe doe jane doe when it should be: john doe jane doe Code:
/* Program name: address_book.cpp |
What's with the string find[1]?
Replacing all occurances of find[1] with find, and the program works as expected. |
thank you connyosis for your help.
|
I guess that when you do string find[1] you're creating an array of strings containing just one string, hence to access that you should use find[0] instead of find[1] since find[1] would be outside the array. (If I'm wrong, somebody correct me)
Of course, it's pretty useless to create an array with just one element instead of just using the string object directly. (That is, just use std::string name instead of std::string name[0]) |
All times are GMT -8. The time now is 05:40 AM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project