broken search can u fix? plz :)

This is a discussion on broken search can u fix? plz :) within the C++ Programming forums, part of the General Programming Boards category; can anyone tell me why this search wont work?? its driving me crazy the code seems ok but it wont ...

  1. #1
    */*/*/*/
    Guest

    broken search can u fix? plz :)

    can anyone tell me why this search wont work?? its driving me crazy the code seems ok but it wont work......any help appreciated, thanks

    Code:
    int SearchDetails(void){
    
    char SearchName[30];
    int n;
    
    cout << "Please Enter Person Name to search: ";
    gets(SearchName);
    
    for(n=0; n<50; n++){
    
        if(SearchName == Names[n].getName()){
              cout << "\n"<< Names[n].getName();
              cout << "\n"<< Addresses[n].getAddress();
              cout << "\n"<< TelNumbers[n].getNumber();
        }
    }
    return -1;
    }

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    148
    Code:
    if(strcmp(SearchName,Names[n].getName()) == 0){
    You are comparing pointer adresses.

  3. #3
    /*/*/*/*
    Guest
    thanks it works now!!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Search Engine - Binary Search Tree
    By Gecko2099 in forum C Programming
    Replies: 9
    Last Post: 04-17-2005, 02:56 PM
  2. searching and insertion in a binary search tree
    By galmca in forum C Programming
    Replies: 1
    Last Post: 03-26-2005, 04:15 PM
  3. Firefox and Google Search
    By DeepFyre in forum Tech Board
    Replies: 0
    Last Post: 01-16-2005, 09:28 AM
  4. Simple search program
    By colinuk in forum C Programming
    Replies: 6
    Last Post: 12-18-2004, 12:58 AM
  5. Can't fix compiler error
    By cgmacewindu in forum C++ Programming
    Replies: 1
    Last Post: 12-02-2002, 03:29 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21