plese help last part does not work

help with searching part using name the last part

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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//Geshu Sinha XI Sc.A
//Project Work
#include<iostream.h>
#include<string.h>
#include<stdio.h>
#include<conio.h>
struct feed              //structure declared
{
char m[4];
char n[4];
};                    //structure declared
struct pat
{
char name[5];          //father's name
char fname[5];
char address[10];
int age;
};
struct diag             //structure declared
{
char probd[5];
char solg[10];
char medg[5];
};
struct doc                    //structure declared
{
char named[5];
char spec[5];
int exp;
};
struct total                //structure declared
{
feed a;
pat b;
diag c;
doc d;
};                             //main program starts
main()
{
cout<<"THE PROGRAM IS MADE WITH AN EFFORT TO EMPHASIZE ON DIGITAL INDIA DEVELOPED INDIA";
total e[10];
int f=0;
cout<<"tell number of patients\n------";
cin>>f;
int g=0;
while(g<f)                                        //while loop to run the program number of times wanted
{
{
   cout<<"Enter 'listp' to get the list of supported places\n------";
   char h[5];
   gets(h);
   if(strcmpi(h,"listp")==0)                  //switch case used
   {
   {
   cout<<"Enter 1 for Delhi\n";
   cout<<"enter 2 for Chennai\n";
   cout<<"Enter 3 for Lucknow\n";
   }
   int i=0;
   cout<<"enter the required option\n";
   cin>>i;
   switch(i)
   {                                             //switch case
   case 1: cout<<"You selected Delhi";break;
   case 2: cout<<"You selected Chennai"; break;
   case 3: cout<<"You selected Lucknow";break;
   }
  cout<<endl;
   cout<<"Enter listh to get list of hospital\n";
   gets(h);
   if(strcmpi(h,"listh")==0)
   {
cout<<"Enter 1 for RML\n";
cout<<"Enter 2 for AIIMS\n";
cout<<"Enter 3 for City Hospital\n";
}
int j=0;
cout<<"enter required option\n";
cin>>j;
switch(j)
{
case 1  : cout<<"You are being connceted to RML\n";           break;
case 2  : cout<<"You are being connected to AIIMS\n";         break;
case 3  : cout<<"You are being connected to City Hospital\n"; break;
}
cout<<endl;
}
g++;
 }
}
cout<<"Now it is time to get details for each Patient\n";    //getting entry for structures
for(int k=0; k<f; k++)
{
cout<<"Tell Patient's name\n";
gets(e[k].b.name);
cout<<"\n";
cout<<"Tell Patient's age\n";
cin>>e[k].b.age;
cout<<"\n";
cout<<"Tell Patient's Father's Name\n";
gets(e[k].b.fname);
cout<<"\n";
cout<<"Tell the address\n";
gets(e[k].b.address);
cout<<"\n";
cout<<"********************************\n";
cout<<"The network transferred to the Doctor\n";
cout<<"Now Doctor will tell  his details and then give the required Diagnostic\n";
cout<<endl;
cout<<"Doctor's name is\n";
gets(e[k].d.named);
cout<<"\n";
cout<<"Now my specialisation is \n";
gets(e[k].d.spec);
cout<<"\n";
cout<<"Now Doctor will tell about his experience(in years)\n";
cin>>e[k].d.exp;
cout<<endl;
cout<<"************************************************************\n";
cout<<"The network tranferred again to the patient\n";
cout<<"Now it's turn of Patient to tell the problem and then Doctor will give the required solution";
cout<<"\n";
cout<<"Tell the problem\n";
gets(e[k].c.probd);
cout<<"\n";
cout<<"My Solution is\n";
gets(e[k].c.solg);
cout<<"\n";
cout<<"You need to take medicine\n";
gets(e[k].c.medg);
cout<<"\n";
cout<<"*****************************************\n";
cout<<"Now it is time for feedback for the task\n";
cout<<"Do you want to give the feedback or not\n";
gets(e[k].a.m);
{
if(strcmpi(e[k].a.m,"y")==0)
cout<<"Give the Feedback\n";
gets(e[k].a.n);
cout<<"\n";
if(strcmpi(e[k].a.m,"y")==1)
cout<<"You never wanted to give feedback(y for yes ohterwise any)\n";
}
}

cout<<"********************************\n";
cout<<"Search using patient's name the data of patient\n";         //search using patient name
char r[5];
clrscr();
cout<<"Tell patient's name to get data for\n";
gets(r);
f=f;
int s=0;
while(s<f)
{
if(strcmpi(r,e[s].b.name)==0)
{
cout<<"Patient's name\n";
puts(e[s].b.name);
cout<<"\n";
cout<<"The problem was\n";
puts(e[s].c.probd);
cout<<"\n";
cout<<"The solution given was\n";
puts(e[s].c.solg);
cout<<"\n";
cout<<"The advised medicine was\n";
puts(e[s].c.medg);
cout<<"\n";
cout<<"The Doctor who gave treatment was\n";
puts(e[s].d.named);
cout<<"\n";
}
s++;
}
cout<<"I hope uou all enjoyed the working and wish India to go on for this";
}



replace all your following staffs

char r[5];
gets(r);
if (strcmpi(r, e[s].b.name) == 0)

to

std::string r;
std::getline(std::cin, r);
if (r == e[s].b.name)

...

If you want to compare case-insensitively, you could still use strcmpi
if (strcmpi(r.c_str(), e[s].b.name) == 0)
Topic archived. No new replies allowed.