Created
          April 30, 2020 06:11 
        
      - 
      
- 
        Save ryangraham/70f0ee694c94b0af645c96590268e14d to your computer and use it in GitHub Desktop. 
    to_lower
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #include <string> | |
| #include <iostream> | |
| char to_upper(char c) | |
| { | |
| // between 97 and 122? | |
| if (c >= 'a' && c <= 'z') | |
| return c ^ 32; // unset 6th bit | |
| return c; | |
| } | |
| char to_lower(char c) | |
| { | |
| // between 65 & 90? | |
| if (c >= 'A' && c <= 'Z') | |
| return c ^ 32; // set 6th bit | |
| return c; | |
| } | |
| int main() { | |
| std::string hexabet = "123456789ABCDEF"; | |
| for(char& c : hexabet) | |
| std::cout << to_lower(c); | |
| std::cout << std::endl; | |
| std::cout << hexabet << std::endl; | |
| return 0; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment