Call a foreign-language function: Difference between revisions

Line 561:
 
=={{header|Fortran}}==
Using the ISO_C_BINDING standard module to link against the C API functions ''strdup'', ''free'' and ''puts''. The program will print two copies of the string ''"Hello, World!"'' using the ''puts'' function. One copy is obtained from ''strdup'', then released with ''free''. The C bindings are placed in an interface module to simplify reuse.
 
<lang fortran>module c_api
use iso_c_binding
Line 591 ⟶ 593:
program c_example
use c_api
implicit none
 
character(20) :: str = "Hello, World!" // c_null_char
Anonymous user