Quantcast
Channel: Tips for golfing in C - Code Golf Stack Exchange
Viewing all articles
Browse latest Browse all 67

Answer by naffetS for Tips for golfing in C

$
0
0

Use bitwise operators to convert characters to uppercase/lowercase. Bitwise AND with 95 (or '_') to convert to uppercase, bitwise OR with 32 (or '') to convert to lowercase, and to invert case, bitwise XOR with 32 (or '').

This only works for letters, and it also seems to work for just a few other characters: { and } are lowercase for [ and ], ~ and ` are lowercase for ^ and @, ) is lowercase for a tab, and * is lowercase for a newline.

Example.


Viewing all articles
Browse latest Browse all 67

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>