help this beginner(now registered)

This is a discussion on help this beginner(now registered) within the C++ Programming forums, part of the General Programming Boards category; Hi, I have registered myself,as I suppose I was violating the rule of being unregistered and asking Qs,so pls atleast ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    7

    Unhappy help this beginner(now registered)

    Hi,
    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.


    Code:
    
    
    validCompName = validateCompetitorName(compName); 
    result = checkDup(database,validCompName);
    int index = unsortedFind(database,tmprec, validCompName);
    
    if(result==1)
    {
    			
           if(index!=-1)
           {
    	while(index<tmprec)
    	{
    		...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;
        displayMainMenu();
       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 ) 
              count++;	
    		
       }
           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;
    	}
    	else
    
    		index++;
    	}
    	return result;
    }

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

    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 http://www.angelfire.com/my/billholm

  3. #3
    Unregistered
    Guest

    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 ...as 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 .....to find the solution....for a problem.

  4. #4
    ¡Amo fútbol!
    Join Date
    Dec 2001
    Posts
    2,136
    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 Cprogramming.com
    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 Cprogramming.com
    Replies: 17
    Last Post: 08-31-2002, 10:34 PM
  5. MSN Vital Information
    By iain in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 09-22-2001, 09:55 PM

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