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
main()
{
char ch[10]="123456";
char *p;
int a;
scanf("%d",&a);
p=ch+a;
*p='0';
printf("%s",ch);
}
output is
nik@debian:~$ ./a.out
4
123406
AND here is other one only have slight change at line [*p='0']
main()
{
char ch[10]="123456";
char *p;
int a;
scanf("%d",&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
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