forked from ChicoState/ColorHex
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
33 lines (26 loc) · 792 Bytes
/
main.cpp
File metadata and controls
33 lines (26 loc) · 792 Bytes
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
#include <iostream>
using std::string;
using std::cout;
using std::getline;
using std::endl;
using std::cin;
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";
}
//Check if input is # using ASCII value
if (input[0] != 35)
{
cout << "Please enter the color in hexadecimal format, starting with # followed by six hex values\n";
}
}
//Check if input is appropriate size then output response
while( input.size() == RGB_HEX_LENGTH );
cout << "Your hex color is: " << input << endl;
return 0;
}