High-level Programming Language (Pascal)
Strings (Sequences of Characters)
String constant
- is a sequence of characters enclosed in single quotation marks, the quotation marks themselves are not part of the string
- some examples,
'Pascal'
'Programming'
'Hello, how are you ?'
'Tom''s computer' (represents the string Tom's computer)
- declaration of string constant
const Message = 'Error ! Please try again.'
String variable
- identifier string is a predefined data type in Pascal, can be used to declare string variables in the var declaration part
- for example,
| var |
Name : string [25]; |
{declared as a string variable which can hold up to 25 characters} |
| |
Class : string [2]; |
{declared as a string variable which can hold up to 2 characters}
{the integer enclosed in the square brackets specifies the maximum number of characters in a value for the string variable}
|
| |
Address : string; |
{if the length is not specified, it is assumed a default maximum length of 255 characters} |
|