i need help to add some code for matching

i need to be able to make matches from the data i input, and also classifying between male and female. matches for person with specific traits (not one in the program) i really tried for the first part and now the rest is mentally disturbing me. and also to generate a report of partners found.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#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();


}
Last edited on
Look at the for loop in match() function:

for(int i=1;i<=10;i++)

You are indexing array of structs with numbers 1-10, but first element in array has index 0

1
2
3
4
for(int i=0; i<10; i++)
{
      cout<<"Enter Information for person number: "<< i+1 <<endl;
      ...
Last edited on
Topic archived. No new replies allowed.