Escape sequence in a string literal (Fortran)

后端 未结 2 410
清酒与你
清酒与你 2021-01-21 07:27

There is an example in C++

string str;
str = "First\\n"
      "Second\\n"
      "Third;\\n";
cout << str << endl;
         


        
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-21 08:05

    One way to do it is to use new_line() intrinsic and // concatenation operator:

    program main
      implicit none
      character(128) :: str
      character      :: NL = new_line("a")
    
      str = "first"//NL//"second"//NL//"third"
      write (*,"(a)") str
    
    end program main
    

提交回复
热议问题