Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access character at specific index in a string in 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?

like image 698
kjh Avatar asked Dec 07 '12 01:12

kjh


People also ask

How do I view a specific index in a string?

You can get the character at a particular index within a string, string buffer, or string builder by invoking the charAt accessor method. The index of the first character is 0; the index of the last is length()-1 .

What is substring in Fortran?

A character datum is a sequence of one or more characters. A character substring is a contiguous portion of a character variable or of a character array element or of a character field of a structured record. A substring name can be in either of the following two forms: v ( [ e1 ] : [ e2 ] )

What is character operator in Fortran?

Fortran has only one character operator, the concatenation operator //. The concatenation operator cannot be used with arithmetic operators.


1 Answers

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.

like image 198
IanH Avatar answered Sep 27 '22 23:09

IanH