Continuous memory allocation is used for 2-d array. So a[2][5] will assign 10 continuous memory spaces. Hello will be stored on the 1st 5 spaces. Hi will be saved on the next 2 consecutive spaces itself. There is no null character saved for the 1st string so while printing it prints until it finds a null character which exists only after hi.
So a[0] prints hellohi and a[1] prints hi 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]); > } -- 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.
