STRUCTURE entered item delete

NEED HELP WIH DELETE ACC 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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
#include <cstdlib>
#include <iostream>



using namespace std;


void exit ();
void DataInput ();
void DataOutput ();
void serch();
void serchdebitori();
void serchaccNum();
void deleteentry();
void summa ();
void correctBalance();

struct clientData
{
       int accNum;	    // konta numurs
       char Sur[15];	// uzvārds
       char Name[10];	// vārds
       float balance;	// balanss (kontā esošā summa vai parāds
}Data[100];





// ====================
// ======Galvenais menu 
// ======================
int main()
{
    int n;
    system("CLS");
    cout << "1.Datu ievade\n";
    cout << "2.Dzest ierakstu\n";
    cout << "3.Meklesana pec parametriem\n";
    cout << "4.Labot konta balansu\n";
    cout << "5.Irakstu summa\n";
    cout << "6.Izvadit paradniekus\n";
    cout << "7.Izvadit visus\n";
    cout << "8.Iziet\n";
    cin >> n;
    switch(n)
    {
    case 1:
         DataInput ();
         break;
    case 2:
         deleteentry();
         break;
    case 3:
         serch ();
         break;
    case 4:
         correctBalance();
         break;
    case 5:
         summa ();
         break;
    case 6:
         serchdebitori();
         break;
    case 7:
         DataOutput ();
         break;
    case 8:
         exit();
         break;                          
    }
    system("PAUSE");
    return EXIT_SUCCESS;
}




// ====================
// ===== Klientu ievade
// ====================

void DataInput ()
{
    int i;
    for (int  i =0; i<100; i++)
    {
    Data[i].accNum;
    if (Data[i].accNum == NULL)
    {
     cout << "Klienta vards\n";
     cin >> Data[i].Name;
     cout << "Klienta uzvards\n";
     cin >> Data[i].Sur;
     cout << "Klienta konta Nr.\n";
     cin >> Data[i].accNum;
     cout << "Klienta summas balanss\n";
     cin >> Data[i].balance;
     main();
     }    
     }
     cin.get();
}




// ==================
// =========== delete 
// ==================

void deleteentry()
{
  
//for (int i = 0;i<10;i++) 
//{
    ///delete [] Data;
//    Data[i].Name = new Data[i].Name;
 //   Data[i].Name = NULL;
 //   delete Data[i].Name;
    //Data[i].Sur = NULL;
 //   Data[i].accNum = NULL;
 //   Data[i].balance = NULL;
//} 
// main ();

 int i;
     int nr; 

  
     cout << "konta numuru\n";
     cin >> nr;
     for (int i = 0;i<100;i++)
     if(nr == Data[i].accNum)
     {
          // delete 
   //    Data[i] = '\0';
     // Data[i].accNum = 0;
    //  Data[i].balance = 0;
      //Data[i].Name = 'i';
    //  Data[i].Sur = 0;      
     }
     main();

}






// ==================
// ====== labot summu 
// ==================

void correctBalance()
{
     int sum1;  
     int nr;   
     cout << "konta numuru\n";
     cin >> nr;
     for (int i = 0;i<100; i++)
     {
     if(nr == Data[i].accNum)
     {
            cout <<Data[i].Name <<" | "<<Data[i].Sur<<" | "<<Data[i].accNum<<" | "<<Data[i].balance<<" EUR"<< endl;
            cout << "Ievadiet summu:\n";
            cin >> sum1;
            Data[i].balance = Data[i].balance + sum1;
            cout <<Data[i].Name <<" | "<<Data[i].Sur<<" | "<<Data[i].accNum<<" | "<<Data[i].balance<<" EUR"<< endl;
     }
     
     }
     system("PAUSE");
     main();
}




// ===================
// =========Datu izvade 
// ======================

void DataOutput ()
{
     
     Data [10];
     for(int i=0; i<10; i++)
     {
     cout <<Data[i].Name <<" | "<<Data[i].Sur<<" | "<<Data[i].accNum<<" | "<<Data[i].balance<<" EUR"<< endl;
     }
     system("PAUSE");
     main();
}




// =======================
// ============= Mekleessana 
// ===========================

void serch()
{
     int n;
     system("CLS");
     cout << "1.Debitori\n";
     cout << "2.Atreat pec konta Nr.\n";
     cout << "3.Main menu\n";
     cin >> n;
     switch(n)
     {
     case 1:
          serchdebitori();
          break;
     case 2:
          serchaccNum();
          break;
     case 3:
         main ();
         break;
     }
}
void summa ()
{
long sum= 0;  
for (int i= 0;i<10;i++)
{
  sum += Data[i].balance;   
    
}     
cout << "-->" << sum << endl;
system("PAUSE");
cin.get();
main();
}




// =============================
// ============= Mekleet debitori 
// =============================

void serchdebitori()
{
     for(int i=0;i<10;i++)
{
     if(Data[i].balance<0)
     {
     cout <<Data[i].Name <<" | "<<Data[i].Sur<<" | "<<Data[i].accNum<<" | "<<Data[i].balance<<" EUR"<< endl;                    
     }        
}
     system("PAUSE");
     main ();
}





// ==============================
// ============== mekleet peec konta numura 
// ==================================

void serchaccNum()
{
     int num;
     cout << "Ievadiet pazaudetas personas konta Nr.\n";
     cin >> num;
     for (int i=0;i<10;i++)
     {
     if(num == Data[i].accNum)
     {
     cout <<Data[i].Name <<" | "<<Data[i].Sur<<" | "<<Data[i].accNum<<" | "<<Data[i].balance<<" EUR"<< endl;      
     }
     } 
     system("PAUSE");
     main ();   
}




// =======================================
// =============== Iziet 
// =====================================

void exit()
{
    
     cout << "Paldies ka izmantojat musu pakalpojumus\n";
     cin.get();
}
You can't call main() as you are doing on lines 101,145,172,196,238,258 and 282. If you put them in so as to get back to main, that happens automatically. If you put them in to recurse, then use a loop. You also don't give any error message or specifics.
i use it to get back to main and it works but i cant delete any input data thats my problem

tryed everything i cann think of so far


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
// ==================
// =========== delete 
// ==================

void deleteentry()
{
  
//for (int i = 0;i<10;i++) 
//{
    ///delete [] Data;
//    Data[i].Name = new Data[i].Name;
 //   Data[i].Name = NULL;
 //   delete Data[i].Name;
    //Data[i].Sur = NULL;
 //   Data[i].accNum = NULL;
 //   Data[i].balance = NULL;
//} 
// main ();

 int i;
     int nr; 

  
     cout << "konta numuru\n";
     cin >> nr;
     for (int i = 0;i<100;i++)
     if(nr == Data[i].accNum)
     {
          // delete 
   //    Data[i] = '\0';
     // Data[i].accNum = 0;
    //  Data[i].balance = 0;
      //Data[i].Name = 'i';
    //  Data[i].Sur = 0;      
     }
     main();

}
i suspect something is wrong at 91 line or something with NULL
Last edited on
damnnnnnn...

still need to figure out how to delete
values in struc

1
2
3
4
5
6
7
  struct clientData	// client data 
{ 
   int accNum;	        // accnr
   char Sur[15];	// surname
   char Name[10];	// name
   float balance;	// balance
};


so far i managet to clear only number and blilance


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void deleteentry()
{
   int i;
     int nr; 

  
     cout << "konta numuru\n";
     cin >> nr;
     for (int i = 0;i<100;i++)
     if(nr == Data[i].accNum)
     {
     Data[i].accNum = 0;
     Data[i].balance = 0; 
     }
     main();

}
Last edited on
LOL * sign did the trick ;)
Last edited on
Topic archived. No new replies allowed.