Access character at specific index in a string in Fortran

白昼怎懂夜的黑 提交于 2020-01-06 16:54:55

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/36487824/fortran-procedure-attribute-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!