remove goto
Does everyone know I can replace goto in this code?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
int main() {
string plainText, left,right, ap="", ke, passKey, rightTerm;
string plainTextBlock[100];
string cipherTextBlock[100];
string decryptedTextBlock[100];
int key1[64];
cout<<"Enter your plain text"<<endl;
getline(cin, plainText);
int len = prexpansionPareText(plainText, plainTextBlock);
pass:;
cout<<"Enter the Key"<<endl;
cin>>passKey;
if (passKey.length()!=8){
cout<<"Key must be 8 characters (64 bits)"<<endl;
goto pass;
}
| |
1 2 3 4 5 6 7 8 9
|
std::string pass_key ;
const int KEY_SZ = 8 ;
do
{
std::cout << "enter key (" << KEY_SZ << " characters): " ;
std::cin >> pass_key ;
// if( pass_key.size() != KEY_SZ ) std::cout << "key must be " << KEY_SZ << " characters\n" ;
}
while( pass_key.size() != KEY_SZ ) ;
| |
Last edited on
@JLBorges
Thanks!
Topic archived. No new replies allowed.