Skip to content

Instantly share code, notes, and snippets.

@davisp
Created November 13, 2014 01:06
Show Gist options
  • Select an option

  • Save davisp/f6b46b4fca28ad9db5ed to your computer and use it in GitHub Desktop.

Select an option

Save davisp/f6b46b4fca28ad9db5ed to your computer and use it in GitHub Desktop.
Apparently char can be an unsigned data type?
#include <stdio.h>
int
main(int argc, char* argv[])
{
fprintf(stderr, "%d\r\n", (char) -1);
fprintf(stderr, "%lu\r\n", sizeof(char));
}
$ uname -a
Darwin prism.local 13.3.0 Darwin Kernel Version 13.3.0: Tue Jun 3 21:27:35 PDT 2014; root:xnu-2422.110.17~1/RELEASE_X86_64 x86_64
$ ./a.out
-1
1
$ uname -a
Linux powerprism 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:09:21 UTC 2014 ppc64le ppc64le ppc64le GNU/Linux
$ ./a.out
255
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment