fortran中字符串读入函数 *,和 ‘(A)’的区别
fortran中字符串读入函数 *,和 ‘(A)’的区别
001、
[root@localhost test]# ls test01.f90 [root@localhost test]# cat test01.f90 program test01_fortran implicit none character(len=30) :: name1 character(len=30) :: name2 print *, "input character1: " read *, name1 ## 默认输入空格被当作字符串分隔符 print *, "input character2: " read '(A)', name2 ## 这里表示格式化字符串输入,空格仍然当作字符串 print *, "name1 = ", name1 print *, "name2 = ", name2 end program test01_fortran [root@localhost test]# gfortran test01.f90 -Wall -O2 -o kkk [root@localhost test]# ls kkk test01.f90 [root@localhost test]# ./kkk input character1: zhang san input character2: zhang san name1 = zhang name2 = zhang san

。

浙公网安备 33010602011771号