1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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,285
    Likes Received:
    364
    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