If you try to visualize the internal representation.
You've allocated 10 bytes.
| h | e | l | l | o |
| h | i |\0 |\0 |\0 |

Since these are stored in linear form, so the actual representation would be
| h | e | l | l | o | h | i |\0 |\0 |\0 |


Now a[0] points to 'h' in the first row, and printf starts to print
characters one by one till it finds null, i.e. \0
Thus it prints from "hellohi"
And similarly printing a[1] prints only "hi"


Regards,
Sandeep Jain




On Mon, Jul 4, 2011 at 1:48 PM, Sangeeta <[email protected]> wrote:

> #include<stdio.h>
> #include<string.h>
> void main()
> {
> char a[2][5]= {
>                     "hellodear",
>                      "hi"};
> printf("%s%s",a[0],a[1]);
> }
> output:hellohi hi
> explain?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to