Thread: array ???????

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

    Unhappy array ???????

    Hi,

    the Q is program should be able to handle mulitple names of a competitor ,if there are mulitple names display it and ask ID for which record changes have to be made. But if the user doesnt want to makes changes he just presses enter key ..(so the previous contents from the database are stored.

    I can search duplicate names ,display them ,display the record with particular ID BUT
    My PROBLEM is I dont know how to preserve the contents if user presess enter key......

    Pls help me out.......
    Thanks a lot.......

    my code relevant to problem:

    Code:
    findRecord(database, tmprec, findArray, totalSelected);
    displayFindRecord(database, findArray, tmprec, totalSelected);
    
    compName = getEditCompetitorName();
    if (!compName.empty())
    {
        validCompName = validateCompetitorName(compName);
    }
    compGender = getCompetitorGender();
    	
    if(!compGender.empty())
    {
        while(!validGenderFormat(compGender))
        {
          cout << "\nError : Invalid gender format, please retry...";
           compGender = getCompetitorGender();
        }
    }
    :
    :
    }

  2. #2
    Registered User
    Join Date
    May 2002
    Posts
    317
    I think I know what your asking. The answer is to place your code that changes the data inside an if statement like so:
    Code:
    if(cin.get(compName, numofcharacters)){
               //your code here
    }
    if cin.get reads a blank line it will return false thus bypassing your code which changes the data. (Note change numofcharacters to the amount you wish to read.) Also in order to input again you will have to place cin.clear(); prior to your next input.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 05-29-2009, 07:25 PM
  2. Replies: 6
    Last Post: 11-09-2006, 03:28 AM
  3. [question]Analyzing data in a two-dimensional array
    By burbose in forum C Programming
    Replies: 2
    Last Post: 06-13-2005, 07:31 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Quick question about SIGSEGV
    By Cikotic in forum C Programming
    Replies: 30
    Last Post: 07-01-2004, 07:48 PM