This is a loop inside other loops, s[]
is a char array. By this I am moving char step by step.what should I do for correcting it
for(k=j; s[k]!='\0' ;k++)
{
s[k]=s[k+1];
}
This is a loop inside other loops, s[]
is a char array. By this I am moving char step by step.what should I do for correcting it
for(k=j; s[k]!='\0' ;k++)
{
s[k]=s[k+1];
}
You should realize that arrays in Java have a length, so your null terminated check is wrong. Since you access the k+1
'th element inside the loop, k
must not go beyond s.length - 2
.
for(k=j; k < s.length - 1 ;k++)
{
s[k]=s[k+1];
}