Well, this can have undefined behavior. Technically you should append - First allocate memory for a string - Then append the terminating char
In this case, the memory location after the last character is set to zero, but then you do not have control over it. It may not be zero when you run it the next time. So it might not terminate. On Sun, Aug 14, 2011 at 10:24 AM, Arshad Alam <alam3...@gmail.com> wrote: > program is running smooth but I have one confusion at line number 8. > why it is while(s[i]!=0) instead of while(s[i]!='\0') > > > > 1. #include<stdio.h> > 2. #include<conio.h> > 3. void main() > 4. { > 5. clrscr(); > 6. char s[]="No two viruses"; > 7. int i=0; > 8. while(s[i]!=0) > 9. { > 10. printf("\n%c %c",s[i],*(s+i)); > 11. printf ( "\n%c %c",i[s],*(i+s)); > 12. i++; > 13. } > 14. getch(); > 15. } > > > > > Thanks & Regards > Arshad Nadeem Alam > > -- > 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. > -- Gaurav Menghani -- 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.