#include<stdio.h>
int main() { char str[10]={'g','k'}; char str1[10]="gh"; int i; for(i=0;str1[i]!=NULL;i++) printf("%c",str[i]); getchar(); } NUll is there in character array also...make clear me... On Sat, Oct 6, 2012 at 9:22 PM, rahul sharma <rahul23111...@gmail.com>wrote: > int main() > { > char str[10]={'g','k'}; > char str1[10]="gh"; > > > printf("%s",str); > printf("%s",str1); > getchar(); > } > then how does this work??? > str printing gk...then NULL is automatically appended in this also...plz > tell > > > On Sat, Oct 6, 2012 at 6:33 PM, Rathish Kannan <rathishkan...@gmail.com>wrote: > >> For string, C appends '\0' internally. hence sizeof(str) returned the >> value 3. >> str1 is char array with two character. hence sizeof(str1) returned the >> value 2. >> >> -- RK :) >> >> >> On Sat, Oct 6, 2012 at 5:53 PM, rahul sharma <rahul23111...@gmail.com>wrote: >> >>> char str[]="ab"; >>> char str1[]={'a','b'}; >>> >>> sizeof(str) ...o/p is 3 >>> sizeof(str1)....o/p is 2.. >>> >>> Why so???? >>> plz explain... >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> 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 algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.