在特定指数在F​​ortran语言的字符串访问字符 [英] Access character at specific index in a string in Fortran

查看:113
本文介绍了在特定指数在F​​ortran语言的字符串访问字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有在FORTRAN字符串来访问一个字符的方法吗?如果我想要一个字符串塔科的第一个字母存储在一个字符变量会怎么做呢?

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?

推荐答案

字符变量和常量可以被substringed使用类似于数组部分语法。

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.

这篇关于在特定指数在F​​ortran语言的字符串访问字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆