Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* This function checks if the given string is a number */
- bool isnumber(const string& str)
- {
- for(auto chr : str)
- if(chr <= '0' && chr >= '9')
- return false;
- return true;
- }
- /* Converts the given char to ascii */
- void convertToAscii()
- {
- try {
- const string& result = input("to_ascii>>>");
- if(isnumber(result)) {
- cout << "1";
- int val = stoi(result);
- if(val >= 1 && val <= 126)
- cout << (char)val << endl;
- else
- throw "The value doesn't correspond to the {1, 126} range";
- }
- else
- throw "The value must be of type int";
- }
- catch(const char* exp) {
- cout << LINE + exp + LINE;
- convertToAscii();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement