Thread: C basic

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2013
    Posts
    2
    Rep Power
    0

    C basic


    what is the difference between the following declarations in terms of memory and internal processing in c?

    >>>> char='a'; Vs string="a";
  2. #2
  3. Contributing User
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jan 2003
    Location
    USA
    Posts
    7,162
    Rep Power
    2222
    How is the Vs type defined? In 23 years of professional C and C++ programming, I have never ever seen it until right now.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2004
    Posts
    20
    Rep Power
    0
    Originally Posted by Viky
    what is the difference between the following declarations in terms of memory and internal processing in c?

    >>>> char='a'; Vs string="a";
    Techically, there is no difference. They are both errors. But answering the question:
    char var = 'a'; defines a single character named var with the value of 'a'

    string var="a"; defines a string variable (essentially a multi-character array) named var with the value of the single character 'a'.

    More characters can be defined or added to a string. They cannot be added to a char since it defines only a single value.

IMN logo majestic logo threadwatch logo seochat tools logo