I'm trying to convert an integer to a binary String (see code below). I've already looked at several similar code snippets, and can't seem to find the reason as to why this does not work. It not only doesn't produce the correct output, but no output at all. Can somebody please explain to me in detail what I'm doing wrong?

```
#include <stdio.h>
#include <stdlib.h>

char* toBinaryString(int n) {
  char *string = malloc(sizeof(int) * 8 + 1);
  if (!string) {
    return NULL;
  }
  for (int i = 31; i >= 0; i--) {
    string[i] = n & 1;
    n >> 1;
  }
  return string;
}

int main() {
  char* string = toBinaryString(4);
  printf("%s", string);
  free(string);
  return 0;
}

```