string - 错误 : Unterminated character constant beginning at (1)

标签 string fortran gfortran fortran77

我想在 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/

相关文章:

c - 将星号传递给c中的字符串

Python 字符串难点

c++ - 迭代器字符串问题

c - 如何从 Fortran 访问 C 指针?

linux - 如何调试 "Program received signal SIGSEGV: Segmentation fault"的错误

java - 字符串对象计数 SCJP

fortran - 在 Fortran2003 中,一维假定形状数组可以与 C 互操作吗?

optimization - `USE` 对性能的影响

gcc - Fortran #define 多行宏定义

fortran - 如何指示 gfortran 仅使用可分配数组的矢量化(最高可用 SIMD)指令来编译循环?