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

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    1

    Values and data values


    This sentence was in my textbook:
    "Although a char value in a program requires apostrophes, a type char data value should not have them."
    What is the difference between a "value" and a "data value"?
    I have a vague idea that the "data value" is the raw data you feed in the program (for example temperature measurements), but I don't know what a "value" is.
  2. #2
  3. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,903
    Rep Power
    1045
    Hi,

    a single sentence without any context doesn't really tell us anything, but I guess what they're talking about is that a char literal (an expression respresenting a char) is written with "apostrophes", but the actual content of a char may not include "apostrophes".

    I have no idea what language you're talking about, so I'll take Java as an example: When you wanna write down a string in Java code, you start with a double quote, write down some characters (which will be the content of the string) and then close the expression with another double quote:

    Code:
    "Hallo world!"
    This is a string expression with two quotes. The content of the string, however, does not include any quotes. It says

    Code:
    Hallo world!
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    1
    Thanks for the answer.

    >I have no idea what language you're talking about
    Sorry about that, I should have included that information.
    I'm studying C.
  6. #4
  7. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,903
    Rep Power
    1045
    Originally Posted by 046
    I'm studying C.
    OK. But in that case, the sentence in the textbook is nonsense. A char may very well contain "apostrophes" (which are single quotes, actually).

    The only special thing about single quotes is that you have to escape them with backslashes when you wanna put them into a char expression. Otherwise the C parser wouldn't be able to distinguish between literal quotes and the quotes enclosing string expressions.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    142
    Rep Power
    1
    The only special thing about single quotes is that you have to escape them with backslashes when you wanna put them into a char expression.
    Thanks for the tip, I'll keep that in mind.

IMN logo majestic logo threadwatch logo seochat tools logo