Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between '...' and "..." in initialising a string? [duplicate]

Tags:

fortran

So, I can initialize a string in Fortran with both

CHARACTER(LEN=4)::string
string = "jklm"

and

CHARACTER(LEN=4)::string
string = 'jklm'

What's the difference?

like image 705
Kama Kashkanov Avatar asked Dec 13 '25 00:12

Kama Kashkanov


1 Answers

At a glance of the fortan docs, it seems the same for the most part. Though if you plan to use a single quote within a string, use a double quote to enclose it.

// correct
"John's Stuff"

// wrong
'John's Stuff'

Alternatively:

// correct
'She said "Hey!"'
// wrong
"She said "Hey!""

http://www.fortran90.org/src/rosetta.html#strings-and-formatting

Edit: btw, same goes for most programming languages.

like image 175
Brian Avatar answered Dec 16 '25 00:12

Brian



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!