Q:

C Memset output

#include <stdio.h>
#include <string.h>

int main() {
  char* p = new char[10];
  memset(p,0,10);
  printf("%c",*p);
}

I suppose memset set every byte starting p to 0. I'm a little surprised to see nothing at all printed out. What on earth was happening for memset?

A:

memset does set all the bytes to 0; thus, when you dereference p, you get a char with value 0 (the NUL byte), and on most systems, printing such a char produces no visible output.  If you want to print the numeric value of the byte instead, use printf("%d", *p);.

