@@ -459,6 +459,49 @@ The result is of the same type as `string`.
459459{!example/strings/example_zfill.f90!}
460460```
461461
462+ <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
463+ ### ` join `
464+
465+ #### Description
466+
467+ Joins an array of strings into a single string. This function concatenates the strings from the input array,
468+ inserting a separator between each string (default: space). A user-defined separator may be provided, The resulting string is returned.
469+
470+
471+ #### Syntax
472+
473+ ` cmd = ` [[ stdlib_strings(module): join (interface)]] ` (strings, separator) `
474+
475+ #### Status
476+
477+ Experimental
478+
479+ #### Class
480+
481+ Pure function
482+
483+ #### Argument
484+
485+ - ` strings ` : Array of strings (either ` type(string_type) ` or ` character(len=*) ` ).
486+ This argument is ` intent(in) ` . It is an array of strings that will be concatenated together.
487+ - ` separator ` : Character scalar (optional).
488+ This argument is ` intent(in) ` . It specifies the separator to be used between the strings. If not provided, the default separator (a space) is used.
489+
490+ #### Result value
491+
492+ The result is of the same type as the elements of ` strings ` (` type(string_type) ` or ` character(len=:), allocatable ` ).
493+
494+ #### Example
495+
496+ ``` fortran
497+ ! Example usage:
498+ program test_join
499+ type(string_type) :: result
500+ type(string_type), dimension(3) :: words = [string_type('hello'), string_type('world'), string_type('fortran')]
501+ result = join_string(words, ', ') ! Joins with comma and space
502+ print *, result ! Output: "hello, world, fortran"
503+ end program test_join
504+ ```
462505
463506<!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
464507### ` to_string `
@@ -498,3 +541,33 @@ The result is an `allocatable` length `character` scalar with up to `128` cached
498541``` fortran
499542{!example/strings/example_to_string.f90!}
500543```
544+
545+ <!-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -->
546+ ### ` to_c_string `
547+
548+ #### Description
549+
550+ Convert a Fortran character string to a C character array.
551+ This function converts a Fortran string into a C-style string, ensuring proper null-termination for use in C functions or libraries.
552+
553+ #### Syntax
554+
555+ ` cstr = ` [[ stdlib_strings(module): to_c_string (function)]] ` (value) `
556+
557+ #### Status
558+
559+ Experimental
560+
561+ #### Class
562+
563+ Pure function.
564+
565+ #### Argument
566+
567+ - ` value ` : Shall be a ` character(len=*) ` string.
568+ This is an ` intent(in) ` argument.
569+ The Fortran string that will be converted to a C character array.
570+
571+ #### Result value
572+
573+ The result is a ` character(kind=c_char) ` array with a dimension of ` len(value) + 1 ` to accommodate the null terminator.
0 commit comments