Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Please comment on these. statements (http://www.go4expert.com/forums/comment-statements-t5389/)

Tech_Khalsa 22Jul2007 20:41

Please comment on these. statements
 
#Why we use loop to access any int or float arrays but not with character array?
#why we need null to terminate string?

shabbir 22Jul2007 20:59

Re: Please comment on these. statements
 
Quote:

Originally Posted by Tech_Khalsa
#Why we use loop to access any int or float arrays but not with character array?

We need to use the loops in both the case to go through each of the elements but in case of scanf / printf it gives us the the special provision of %s hiding behind the going through each elements. I am not sure about the implementations of the functions though.
Quote:

Originally Posted by Tech_Khalsa
#why we need null to terminate string?

We need to make compiler understand that thats it we are done with the number of characters we want in the string and so we use a character and that is NULL.


All times are GMT +5.5. The time now is 22:02.