By char a[3]={'a','b'}; you are implicitly assigning a zero to a[2] which is what makes the array a string.
>So, my query is, why this is happening only in case of strings and not for the others( like int, float, single character)?
Because you can't do this printf("%s",a); if variable a were an array of floats or ints.
Reputation Points: 2224
Solved Threads: 218
Nearly a Posting Maven
Offline 2,304 posts
since Dec 2006