Thread: help this beginner(now registered)

  1. #1
    Registered User
    Join Date
    May 2002

    Unhappy help this beginner(now registered)

    I have registered myself,as I suppose
    I was violating the rule of being unregistered
    and asking Qs,so pls atleast now help me out!!

    the Q is if there are multiples of a single name in the database ,that records should be displayed and
    user should be asked to type in the ID.....for which particular name he wants to make changes.......

    I was able to find duplicate names but I just cant
    understand when I type in the right ID then too
    it displays the message
    "ID not found"
    Please look at my code,and pls let me know where I am going wrong......
    I would really appreciate if someone help this beginner.

    validCompName = validateCompetitorName(compName); 
    result = checkDup(database,validCompName);
    int index = unsortedFind(database,tmprec, validCompName);
    		...display that particular records...								index ++;
       cout<<"Multiple entries found"<<endl;
       cout<<"pls type ID"<<endl;
        sID = getID();
        validID = validateID(sID,tmprec);
        ID = atoi(validID.c_str());
       if(database[index].ID!= ID)
         cout<<"ID not found"<<endl;
       option =getMenuOption();
       else if(database[index].ID==ID)
          compName = getCompetitorName();
          validCompName = validateCompetitorName(compName);
          cout<<"record edited"<<endl;
    int checkDup ( competitor database[], string name )
     for(int x= 0; x<DATABASESIZE;x++)
             if ( database[x].competitorName == name ) 
           return ( count > 1 ) ? 1 : 0;
    int unsortedFind(const competitor database[], const int tmprec, string name)//tmrec = no. of records currently in an array
    while(index <tmprec)
    	if (name == database[index].competitorName)
    			result = index;
    			index = tmprec;
    	return result;

  2. #2
    Registered User billholm's Avatar
    Join Date
    Apr 2002

    Lightbulb Hmmm...

    Hello cute little newbie!

    I have no compiler here in the internet cafe so I just did a manual evaluation of your code.

    I think this is your problem:

    ID = atoi(validID.c_str());

    I don't know if atoi() can evaluate a function, even if it returns a string.

    If no conversion takes place, then atoi() returns a NULL and your ID may then have a zero value, which of course (I think), is not a valid ID in your database.

    How bout tryin' this:

    char *string;

    string = validID.c_str();
    ID = atoi(string);

    Compile it and inform me if I'm mistaken.
    All men are created equal. But some are more equal than others.

    Visit me at

  3. #3

    Smile Thanks

    Thanks for ur reply....
    it was not problem of atoi function, I was not incrementing the index value,thats why it was just comparing with 0 I had initiliazed the index to 0;
    But thanks a lot anyway for the ur courtesy of replying to my thread.
    There r still good people out there ,who give the helping hand who r really struggling hard find the solution....for a problem.

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    There is no unwritten rule of not helping Unregistereds. It is just that your code is incomplete so the problem may not be pinpointable. Also, you included a great deal of code which causes lazy people (like me ) to skip it. Hence, if you can pinpoint your problem by using your compiler errors, we might be able to help you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. registered vs unregistered ddr ram?
    By doubleanti in forum A Brief History of
    Replies: 5
    Last Post: 11-29-2006, 08:13 PM
  2. Registered name?
    By Pyroteh in forum Tech Board
    Replies: 2
    Last Post: 01-19-2005, 01:38 PM
  3. Obtaining a list of all registered window classes?
    By Sebastiani in forum Windows Programming
    Replies: 4
    Last Post: 01-05-2003, 04:15 AM
  4. Thought I'd registered last couple of months...
    By Grayson_Peddie in forum A Brief History of
    Replies: 17
    Last Post: 08-31-2002, 09:34 PM
  5. MSN Vital Information
    By iain in forum A Brief History of
    Replies: 9
    Last Post: 09-22-2001, 08:55 PM