My program is to reverse, even though the reverse is being generated but the problem is there is an unwanted junk values too.
I am not able to understand where the problem is.
You need to add
b[i] = 0;
at the end to terminate the string.