Regarding strings

Discussion in 'C' started by arvind_khadri, Sep 5, 2007.

  1. arvind_khadri

    arvind_khadri New Member

    Joined:
    Sep 4, 2007
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    0
    hi all....i wanted to know wat is a string(other than being a array of characters,define it in some other way)......then why do we put '\0' at the end of string.....and are there diff types of strings.....
     
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    Code:
    myString [] = "This is a string".
    
    That (myString) is a C string. The '\0' at the end (not shown) is there to show the end of the string, since two strings might be contiguous in memory and appear to be one long string without the terminator. I hope this helps, though there seems to be little point in describing it in some way other than an array of characters terminated by zero. That's a perfectly good definition.

    The string class available in C++ is another thing entirely.
     
  3. arvind_khadri

    arvind_khadri New Member

    Joined:
    Sep 4, 2007
    Messages:
    22
    Likes Received:
    0
    Trophy Points:
    0
    hey thanks...but i wanted to know tat do we have diffreent types of strings in C itself for example like we have *file pointers* nd *function pointers*....
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    A C string is a C string. There is only one kind of 'string', and that is composed of chars. You might say, "I have a long string of integers", and that would be a perfectly good English statement. However, the use of the word "string" does not imply a C entity, merely a verbal communication. You're trying to complicate something that's simple.
     

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