title: sizes and arrays in c
body: <p>i'm following cLearnthehardway at exercise 8 the following code was written , i have 2 questions</p>
  
  <ul>
  <li>while printing and integers it used %ld to print them not %d !!</li>
  <li>while printing areas[10]//out of range it printed 0! why didn't it show me an error while it does by valgrind(6erros)</li>
  </ul>
  
  <hr>
  
  <pre><code>#include&lt;stdio.h&gt;
  
  int main(int argc,char *argv[])
  {
  
  int areas[]={10,12,13,14,20};
  char name[]="Zed";
  char full_name[]={'Z','e','d',' ','A','.',' ','S','h','a','w','\0'};
  
  printf("The size of an int: %ld\n", sizeof(int));//why didn't we use %d instead of %ld(*)
  printf("The size of areas (int[]):%ld\n",sizeof(areas));//*
  printf("The number of ints in areas : %ld\n",sizeof(areas)/sizeof(int));//*
  printf("The first area is %d, the second area is %d\n",areas[0],areas[1]);//Printed areas[10]=0!!
  printf("The size of a char is: %ld\n",sizeof(char));//*
  printf("The size of name(char[]) is:%ld\n",sizeof(name));//*
  printf("The number of chars is : %ld\n",sizeof(name)/sizeof(char));//*
  printf("the size of FULL NAME  (char[]) is:%ld\n",sizeof(full_name));//*
  printf("The number of chars in full name is %ld\n",sizeof(full_name)/sizeof(char));//*
  printf("name=\"%s\" and full name =\"%s\"\n",name,full_name);// what is \"%s\" \ is an    ESCAPE
  
  
  return 0;
  }
  </code></pre>