How can I print the apostrophe sign in Pascal using the writeln
function?
Example:
writeln('My brother's book');
wouldn't work because s book
is out of "writing" function, so the compiler returns an error:
Fatal: Syntax error, ")" expected but "identifier S" found
Fatal: Compilation aborted
write\writeln For this, Pascal has the predefined functions write and writeln. The syntax is write(outputdata) or writeln(outputdata), where outputdata is any variable or a text you specify. If it is text, you have to give it in quotes, that is like write('I'm a student'). Do not forget the semicolon after each line.
WriteLn does the same as Write for text files, and emits a Carriage Return - LineFeed character pair after that. If the parameter F is omitted, standard output is assumed. If no variables are specified, a newline character sequence is emitted, resulting in a new line in the file F .
Definition and Usage The writeln() method writes directly to an open (HTML) document stream. The writeln() method is identical to the write() method, with the addition of writing a newline character (U+000A) after each statement.
According to the Free Pascal Reference: The single quote character can be embedded in the string by typing it twice:
writeln('By brother''s book');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With