title: cannot understand why malloc function in c is doing as explained below?
body: <p>When i wrote the following code i got weird answers.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  main()
  {
  int *p=malloc(1);
  if(p==0)
  printf("memory not assigned\n");
  else
  {
  printf("memory assigned\n");
  printf("enter an int\t");
  scanf("%d",p);
  printf("\n You entered number %d",*p);
  printf("\nIt has been stored at-%p",p);
  }
  }
  </code></pre>
  
  <p>I think malloc takes argument as number of byte.so here i entered 1 byte and i know that on my machine int requires 4 bytes for storage(through sizeof()) but still the code shows no error and i can enter an int value.even if i enter 3333333 it does not complain.if i use malloc() instead of malloc(1) gcc complains of too few argument for malloc but still gives the same result.I cant understand this behaviour.will someone please clarify it.</p>
  
  <p>I am running it on gcc through virtual box.</p>