我想检查两个字符串是否相等并做一些工作。
character(len = 50) :: x, y ,z
x="amin"
y="amin"
if(llt(x, y)) then
z=x
end if
我写了这个,但它只是检查字符串中的第一个字符。 我该如何处理?
最佳答案
在 Fortran 中,两个字符串可以通过关系运算进行比较,即 <
, >
, ==
, /=
, etc. .
所以在你的情况下:
if ( x == y ) then
z = x
end if
llt()
函数做了完全不同的事情:
The
llt()
function tests whether a string is lexically less than another string based on the ordering of the ASCII collating sequence.
关于string - Fortran中如何检查两个字符串是否相等?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59739472/