title: char array with pointer in c with %s
body: <p>i have these two c programming code .They are identical except for one step and because of that their output is totally different please help me why is this happening </p>
  
  <pre><code>main()
  {
  char ch[10]="123456";
  char *p;
  int a;
  scanf("%d",&amp;a);
  p=ch+a;
  *p='0';
  printf("%s",ch);
  } 
  
  output is 
  nik@debian:~$ ./a.out 
  4
  123406
  </code></pre>
  
  <p>AND here is other one only have slight change at line [*p='0'] </p>
  
  <pre><code>main()
  {
  char ch[10]="123456";
  char *p;
  int a;
  scanf("%d",&amp;a);
  p=ch+a;
  *p=0;        //only change is here rest is same
  printf("%s",ch);
  } 
  
  and output is
  nik@debian:~$ ./a.out 
  4
  1234
  </code></pre>
  
  <p>please hep me out why it is defferent it is because i am using %s in printf or for other thing which i have been missing </p>