GNU Scientific Library Reference Manual - Third Edition (v1.12)by M. Galassi, J. Davies, J. Theiler, B. Gough, G. Jungman, P. Alken, M. Booth, F. Rossi Paperback (6"x9"), 592 pages, 60 figures ISBN 0954612078 RRP £24.95 ($39.95) |

## 9.7 Reading and writing permutations

The library provides functions for reading and writing permutations to a file as binary data or formatted text.

__Function:__int**gsl_permutation_fwrite***(FILE **`stream`, const gsl_permutation *`p`)- This function writes the elements of the permutation
`p`to the stream`stream`in binary format. The function returns`GSL_EFAILED`

if there was a problem writing to the file. Since the data is written in the native binary format it may not be portable between different architectures.

__Function:__int**gsl_permutation_fread***(FILE **`stream`, gsl_permutation *`p`)- This function reads into the permutation
`p`from the open stream`stream`in binary format. The permutation`p`must be preallocated with the correct length since the function uses the size of`p`to determine how many bytes to read. The function returns`GSL_EFAILED`

if there was a problem reading from the file. The data is assumed to have been written in the native binary format on the same architecture.

__Function:__int**gsl_permutation_fprintf***(FILE **`stream`, const gsl_permutation *`p`, const char *`format`)- This function writes the elements of the permutation
`p`line-by-line to the stream`stream`using the format specifier`format`, which should be suitable for a type of`size_t`. In ISO C99 the type modifier`z`

represents`size_t`

, so`"%zu\n"`

is a suitable format.^{(7)}The function returns`GSL_EFAILED`

if there was a problem writing to the file.

__Function:__int**gsl_permutation_fscanf***(FILE **`stream`, gsl_permutation *`p`)- This function reads formatted data from the stream
`stream`into the permutation`p`. The permutation`p`must be preallocated with the correct length since the function uses the size of`p`to determine how many numbers to read. The function returns`GSL_EFAILED`

if there was a problem reading from the file.

ISBN 0954612078 | GNU Scientific Library Reference Manual - Third Edition (v1.12) | See the print edition |