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.
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:
This is a string expression with two quotes. The content of the string, however, does not include any quotes. It says
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.
June 10th, 2013, 12:06 AM
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.
June 10th, 2013, 06:53 AM
Thanks for the tip, I'll keep that in mind.