13

I'm just starting out on Fortran and am confused with the usage of double vs single quotation marks.

nbro
  • 12,226
  • 19
  • 85
  • 163
Zen
  • 186
  • 2
  • 8
  • This is a good question. As has been answered already, there are only subtle differences when formatting output. This is in contrast to C or C++, where they enclose different data structures. – Raul Laasner Jun 23 '15 at 08:53

2 Answers2

14

They are equivalent. There is no difference in their usage.

You can employ this to print one of the quotation characters:

print *, "'"

print *, '"'

prints first ' and then ".

Note: You can also use two quote characters in a row to print one:

print *, """"

print *, ''''

prints first " and then '.

Vladimir F
  • 50,383
  • 4
  • 60
  • 96
0

Functionally they have no difference. Just try to be consistent about which one you use. If your strings tend to have double quotes in them, use single quotes everywhere; if you use single quotes more often, use double quotes to delimit your strings.

As an additional note, it is possible to escape the quote character inside a string: (i.e. 'You\'re') but most people would suggest using it doubled up as they would find it more readable (i.e. 'You''re').