Ik heb het volgende stukje geprogrammeerd, maar zodra ik bij naam een te lange string invoer blijft hij hangen in de while loop omdat hij die string in het geheugen houd, is er iemand die weet hoe ik hem weer leeg kan gooien??
code:
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
| #include <iostream.h>
void Invoer()
{
char Invoer_Naam[41] = "", Invoer_Adres[41] = "", Invoer_Postcode[7], Invoer_Plaats[20], Invoer_Telefoon[20];
while( strlen( Invoer_Naam ) < 1 || strlen( Invoer_Naam ) > 40 )
{
cout << "Naam: ";
cin.getline( Invoer_Naam, 41 );
}
cout << "Adres: ";
cin.getline( Invoer_Adres, 41 );
while( strlen( Invoer_Postcode ) != 6 )
{
cout << "Postcode: ";
cin.getline( Invoer_Postcode, 7 );
}
cout << "Plaats: ";
cin.getline( Invoer_Plaats, 20 );
cout << "Telefoon: ";
cin.getline( Invoer_Telefoon, 20 );
}
int main()
{
Invoer();
return 0;
} |
[ Voor 10% gewijzigd door Verwijderd op 18-12-2002 20:57 ]