Thread: Need help in continuing my matching program for matching people according to traits

  1. #1
    Registered User
    Join Date
    Oct 2014
    Posts
    1

    Need help in continuing my matching program for matching people according to traits

    so basically i need a program that allows a clerk to enter details. Then log in using those details. Then the clerk is required to enter details of of 10 people. details are:- Name, age,Gender, height, region and No. of past relationships. one he enters these details they are saved. now these details are of 10 different people. he then enters a clients requirements (which are specific details of the match he/she is looking for) if no match is found it displays "no match found" and if results have matches, a report is made of the people with their details.

    Code:
    #include<string.h>#include <iostream>
    using namespace std;
        char username[20];
        char storedusername[20];
        char password[20];
        char storedpassword[20];
        int loginresult;
        char name[20];
    
    
    
    
    
    
    
    
     int login()
     {
     
     
        int logins;
        
        cout<<"username";
        cin>>username;
        cout<<"password";
        cin>>password;
        
        if((strcmp(username ,storedusername)==0)&&(strcmp(password,storedpassword)==0))
        {
            logins=1;
        }
        
        else
        {
            logins=0;
        }
        
        return logins;
    }
    
    
    
    
    
    
    
    
    
    
    
    
     void rregister ()
    {
        cout<<"enter your name"<<endl;
        cin>>name;
        cout<<"enter your username:";
        cin>>storedusername;
        cout<<"enter your password:";
        cin>>storedpassword;
    }
    
    
    
    
    
    
    
    
    
    
      void match()
    {
    //*create structures to store information of the people to be matched*/
    
    
    struct person
    {
    char name [20];
    int age;
    char region[20];
    int pastr;
    int height;
    };
    
    
    //*create an array to hold the structures that have information on people to be matched*/
    
    
    struct person arrayOfStructures[10];
    
    
    //*Enter the information of the people to be matched useing for loop*/
    
    
    for(int i=1;i<=10;i++)
    {
    cout<<"Enter Information for person number: "<< i <<endl;
    cout<<"NAME: ";
    cin>> arrayOfStructures[i].name;
    cout<<"AGE: ";
    cin>> arrayOfStructures[i].age;
    cout<<"REGION: ";
    cin>> arrayOfStructures[i].region;
    cout<<"PAST RELATIONSHIPS: ";
    cin>> arrayOfStructures[i].pastr;
    cout<<"HEIGHT: ";
    cin>> arrayOfStructures[i].height;
    }
    
    
    }
    
    
    
    
    
    
    
    
    int main()
    {
    
    
        
        rregister();
        
        cout<<"Registration successfull "<<endl;
        
        cout<<"Enter username and password to login "<<endl;
        
        
        loginresult=login();
        
        //if(loginresult!=1)
        
        while(loginresult!=1)
        {
            cout<<"username or password is incorrect signn in again "<<endl;
            loginresult=login();
           
        }
        
        cout<<"login success ";
        
        match();
    
    
    }
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    May 2010
    Posts
    4,452
    Do you have a question/problem with your code?

    Why all the global variables?

    You should find and consistently use an indentation style you like, it'll make your program easier to read. And IMO you have a few too many blank lines.

    Jim

  3. #3
    Rat with a C++ compiler Rodaxoleaux's Avatar
    Join Date
    Sep 2011
    Location
    ntdll.dll
    Posts
    203
    Reading that code makes my eyes water.
    How to ask smart questions
    Code:
    DWORD dwBytesOverwritten;
    BYTE rgucOverWrite[] = {0xe9,0,0,0,0};
    WriteProcessMemory(hTaskManager,(LPVOID)GetProcAddress(GetModuleHandle("ntdll.dll"),"NtQuerySystemInformation"),rgucOverWrite,5,&dwBytesOverwritten);

  4. #4
    Registered User Alpo's Avatar
    Join Date
    Apr 2014
    Posts
    877
    Code:
    //*create structures to store information of the people to be matched*/
     
     
    struct person
    {
    char name [20];
    int age;
    char region[20];
    int pastr;
    int height;
    };
     
     
    //*create an array to hold the structures that have information on people to be matched*/
     
     
    struct person arrayOfStructures[10];
    It's not necessary to include 'struct' in the definition in C++. As general advice, I would say you need to encapsulate things more. You can make classes out of both the login details, and person. Then you could store the 'person' class in either a std::vector or maybe a std::map. Also, use std::string instead of char arrays, they are much easier to work with.
    WndProc = (2[b] || !(2[b])) ? SufferNobly : TakeArms;

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Matching numbers
    By kirksson in forum C Programming
    Replies: 7
    Last Post: 07-23-2008, 01:51 PM
  2. Parsing and Matching....
    By joseph0829 in forum C++ Programming
    Replies: 6
    Last Post: 01-18-2007, 11:47 AM
  3. file matching
    By ercumania in forum C Programming
    Replies: 7
    Last Post: 07-24-2006, 12:34 PM
  4. Program does not find any matching file
    By tilex in forum Windows Programming
    Replies: 1
    Last Post: 10-01-2005, 09:59 PM
  5. Matching the brackets
    By coskun in forum C Programming
    Replies: 27
    Last Post: 07-30-2004, 11:41 AM

Tags for this Thread