RSS Forums RSS
Please support our C++ advertiser: Programming Forums
Views: 875 | Replies: 3
Join Date: Jan 2007
Posts: 16
Reputation: iaaan is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
iaaan iaaan is offline Offline
Newbie Poster

Searching array problems

  #1  
Feb 12th, 2007
Hey, i am trying to search an array of surnames. I am entering in a surname, and if that surname is in the array, i want to to bring out all other details for that surname that are stored in a structure. At the moment, i have this working for the reference number. The code for that is:

cout << "Please enter an associate reference number :" << endl;
cin >> SearchNum;

while((RecNum < MAX_QUOTES) && (SearchNum != Quote[RecNum].RefNumber))

{
RecNum++;
}


This then, if found, out puts all the details in the Quote structure for all the details of that record number.

However, when i try this for the surname, which is very similar, it doesn't work:

cout << "\n\nPlease enter an associate surname :" << endl;
cin.getline(SearchName,NAME_LEN);

while((RecNum < MAX_QUOTES) && (SearchName != Quote[RecNum].Surname))

{
RecNum++;
}


SearchName takes in the surname i enter along with some other stuff after it. I was wondering how to get rid of all the stuff after the surname to get this to work. I think its something to do with '/0' but that just stores up the remaining space with /0. It wont bring out the results for Snape as searchname is stored as Snape/0/0/0/0.

Any help would be great.

Ian
Last edited by iaaan : Feb 12th, 2007 at 2:01 pm.
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 2:15 am.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC