Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

F_C_STRING

Intrinsic Module Function (Generic): Creates a C null terminated string from a Fortran string.

Module

USE, INTRINSIC :: ISO_C_BINDING

Syntax

F_C_STRING (string[, asis])

string

(Input) Is a scalar character of kind C_CHAR.

asis

(Optional, input) Is a LOGICAL scalar.

Results

The result is a scalar character of type C_CHAR. If asis is present and has the value .TRUE., the length parameter of the result has a value equal to LEN (string) + 1, and the result has the value equal to string // C_NULL_CHAR.

If asis is present with the value .FALSE., or if asis is not present, the length parameter of the result has a value equal to LEN (TRIM stringstring)) + 1, and the result has the value equal to TRIM (string) // C_NULL_CHAR.

Example

If STRING is declared as CHARACTER(LEN=7, KIND=C_CHAR) and it has the value "12345 " (two trailing blanks), then F_C_STRING () has the value "12345"//C_NULL_CHAR, and F_C_STRING (STRING, .TRUE.) has the value "12345 "//C_NULL_CHAR.