访问 Fortran 字符串中特定索引处的字符 [英] Access character at specific index in a string in Fortran
本文介绍了访问 Fortran 字符串中特定索引处的字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在 fortran 中访问字符串中的字符?如果我想将字符串taco"的第一个字母存储在字符变量中,我该怎么做?
Is there a way to access a character in a string in fortran? If I wanted to store the first letter of a the string "taco" in a character variable how would I do that?
推荐答案
可以使用类似于数组部分的语法对字符变量和常量进行子字符串化".
Character variables and constants can be "substringed" using a syntax similar to an array section.
a_character_variable = "taco"(1:1)
字符变量的子字符串也是变量 - 它可能出现在赋值语句的左侧.
A substring of a character variable is also a variable - it may appear on the left hand side of an assignment statement.
这篇关于访问 Fortran 字符串中特定索引处的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文