data base :)

ok here is a deal i'm making simple database but im a little stuck... i can only add one client right now but it would be nice if i could add more... hope its clear what i try to make any tips or hints would e nice
:)

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
  struct clientData
{
       int accNum;	    
       char Sur[15];	
       char Name[10];	
       float balance;	
}Data[10];


}

void DataInput ()
{
    int i;
     
     //if (!(Data[i].Name == NULL))
     //{
     do
     {
     int i=0;     
     i++;
     Data[i];
     //cout << "Name\n";
     //cin >> Data[i].Name;
     //cout << "SurName\n";
     //cin >> Data[i].Sur;
     //cout << "AccNum\n";
     //cin >> Data[i].accNum;
     //cout << "balance\n";
     //cin >> Data[i].balance;
     //}
     //else 
     //{
     }
     while(Data[i].Name == NULL);     
     cout << "PName\n";
     cin >> Data[i].Name;
     cout << "SurName\n";
     cin >> Data[i].Sur;
     cout << "AccNum\n";
     cin >> Data[i].accNum;
     cout << "balance\n";
     cin >> Data[i].balance;
     //}
     cin.get();
     main();
}
The first thing I see is that call to main(). Calling main() from any function, including main(), is not allowed in a C++ program. You should just let the function return to the calling function.

Next what do you mean by you "only add one client", you have an array so it appears you could have more than one client if you structured your program properly.

Lastly what are you "stuck" on?

when i enter client and than i add new one it replaces existing one but not starting new entry :)
Help me please
this is how far i have gone
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
#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[10];





// ====================
// ======Galvenais menu 
// ======================
int main()
{
    int n;
    system("CLS");
    cout << "1.Datu ievade\n";
    cout << "2.Dzest\n";
    cout << "3.Atrast 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.Exit\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<2; i++)
    {   
     cout << "Personas vards\n";
     cin >> Data[i].Name;
     cout << "Personas uzvards\n";
     cin >> Data[i].Sur;
     cout << "Personas konta Nr.\n";
     cin >> Data[i].accNum;
     cout << "Summa\n";
     cin >> Data[i].balance;
     }
     cin.get();
     main();
}




// ==================
// =========== 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;
    delete [] Data;
} 
 main ();
}




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

void correctBalance()
{
     int sum;
     int sum1;     
     cout << "Ievadiet meklejamo summu\n";
     cin >> sum;
     for (int i = 0;i<10; i++)
     {
     if(sum == Data[i].balance)
     {
            cout << "Ievadiet summu:\n";
            cin >> sum1;
            Data[i].balance + sum1;
     }
     
     }
     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<< 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<< 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<< endl;      
     }
     } 
     system("PAUSE");
     main ();   
}




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

void exit()
{
    
     cout << "Paldies ka izmantojat musu pakalpojumus\n";
     cin.get();
}



still doesnt work section 1 data input cause programm asks to enter all inputs at once dont know how to add one by one
there fore section 2 or delete doesnt work

and section 4 doesnt work where you cann edit any of sum
still to fix

1. input
2. delete

fixed
section 4

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
// ==================
// ====== labot summu 
// ==================

void correctBalance()
{
     int sum1;  
     int nr;   
     cout << "konta numuru\n";
     cin >> nr;
     for (int i = 0;i<10; 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();
}
Topic archived. No new replies allowed.