Skip to content

Commit

Permalink
Repeats for wrong length input
Browse files Browse the repository at this point in the history
  • Loading branch information
kbuffardi committed Sep 19, 2023
1 parent 00091d8 commit ce2805d
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <iostream>

using namespace std;
const int RGB_HEX_LENGTH = 7;

int main(){
string input;

do{
cout << "Enter a color in hex format (#RRGGBB):";
getline(cin, input);

if( input.size() != RGB_HEX_LENGTH ){
cout << "Please enter the color in hexadecimal format, starting with # followed by six hex values\n";
}
}while( input.size() != RGB_HEX_LENGTH );

cout << "Your hex color is: " << input << endl;

return 0;
}

0 comments on commit ce2805d

Please sign in to comment.