Skip to content

Instantly share code, notes, and snippets.

@zed
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save zed/ba2de81701a187cbbd83 to your computer and use it in GitHub Desktop.

Select an option

Save zed/ba2de81701a187cbbd83 to your computer and use it in GitHub Desktop.
// show that c99 isspace returns the same result for char and unsigned char
#include <algorithm>
#include <cctype>
#include <climits>
#include <iostream>
int main() {
for (char c = CHAR_MIN; ; ++c) { // iterate over all char values
unsigned char u = c;
if (::isspace(c) != ::isspace(u)) { // error
std::cerr << static_cast<int>(c) << std::endl;
return 1;
}
if (c == CHAR_MAX)
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment