我想在 Fortran 代码中使用多行字符串。我试着这样做:
print *, "Line 1&
&line 2"
但是在编译文件 gfortran myfile.f
时它给我语法错误:
Error: Unterminated character constant beginning at (1)
如何以干净的方式拥有多行字符串?
最佳答案
可以使用字符串连接轻松完成。示例(在自由格式的 .f90 文件中):
write(*,'(A)') 'Line 1'//&
'line 2'//&
'and so forth'
关于string - 错误 : Unterminated character constant beginning at (1),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37254720/