Please comment on these. statements

Discussion in 'C' started by Tech_Khalsa, Jul 22, 2007.

  1. Tech_Khalsa

    Tech_Khalsa New Member

    Joined:
    Jul 22, 2007
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    #Why we use loop to access any int or float arrays but not with character array?
    #why we need null to terminate string?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,374
    Likes Received:
    388
    Trophy Points:
    83
    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.
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice