In C++ a string is more than one character even though a single character can be identified as a string. We'll clear this up later.
Examples:
"abcdefghijklmnopqrstuvwxyz"
"12345678910"
"*%4_0a^abcdYYY#@"
"12345678910"
"*%4_0a^abcdYYY#@"
Notice that in C++, strings are identified by the quotes " around the characters. C++ uses the double quote (") for strings
A character is identified in C++ using single quotes.
Examples:
'a'
'b'
'1'
'8'
'b'
'1'
'8'
Each character is identified by single quotes. In C++, you are not allowed to have more than one character inside the single quotes.
A string, however, can have more than one character. It can even have a single character, however, to identify it as a C++ string, you have to use double quotes.
"a" -- This is a string
'a' -- This is a single character
No comments:
Post a Comment