Software, technology, sysadmin war stories, and more. Feed
Tuesday, March 13, 2012

These bits matter

Sometimes, the simple ones can make for the best conversations.

#include <stdio.h>
int main() {
  int a = 1, i;
  char* ch = (char*) &a;
  for (i = 0; i < sizeof(int); ++i) {
    printf("%d: %d\n", i, ch[i]);
  return 0;

Sure, they can tell you what it'll print ... some of the time, that is ... but the better question is: why is it doing that? Then later on, you might ask why it even matters, and what you have to do about it.

"I don't know" is an acceptable answer. Making stuff up never is.