Skip to content

Instantly share code, notes, and snippets.

@Tricky1975
Last active February 1, 2019 15:18
Show Gist options
  • Save Tricky1975/0b50b8c39d709304f717317ce61fba9a to your computer and use it in GitHub Desktop.
Save Tricky1975/0b50b8c39d709304f717317ce61fba9a to your computer and use it in GitHub Desktop.
A very simple program in C that quickly gets all signed chars from 0 till 255 and their unsigned counter parts and hex code.
#include <stdio.h>
typedef
union
mc {
char rc;
unsigned char uc;
} mychar;
mychar ch;
int main() {
ch.uc=0;
for (int i=0;i<256;i++){
printf("unsigned %3d; signed %4d; hex %0X\n",ch.uc,ch.rc,ch.uc);
ch.uc++;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment