V.._write and V.._nwrite: C/C++ only! (OptiVec vector function)">V_write, V_nwrite:, C/C++, only!">
VF_setWriteFormatVD_setWriteFormatVE_setWriteFormat
VCF_setWriteFormatVCD_setWriteFormatVCE_setWriteFormat
VPF_setWriteFormatVPD_setWriteFormatVPE_setWriteFormat
VI_setWriteFormatVBI_setWriteFormantVSI_setWriteFormat
VLI_setWriteFormatVQI_setWriteFormat
VU_setWriteFormatVUB_setWriteFormatVUS_setWriteFormat
VUL_setWriteFormatVUI_setWriteFormat
FunctionDefinition of the format to be used by V.._write and V.._nwrite: C/C++ only!
Syntax C/C++#include <VFstd.h>
void VF_setWriteFormat( char *FormatString );
C++ VecObj#include <OptiVec.h>
void vector<T>::setWriteFormat( char *FormatString );
DescriptionThe functions of the VF_write and VF_nwrite families employ internally the ANSI C function fprintf in order to print numbers into a stream.
According to the rules described in the documentation of your C compiler's printf function, the format may be specified as fits your needs. When defining a write format, one should always be aware of the restrictions imposed by the read functions (not all formats you can write will be read correcly, see VF_read).

VF_setWriteFormat should not be used for the definition of whitespace before or after the numbers. This is the task of VF_setWriteSeparate.

For details about the formats used for each of the various data types, please refer to the following table. The last column of this table gives the maximum length of the format string.

VersionStandard FormatAlternative Examplemax. length
VF_"% 11.8e""% 8.4f"16
VD_"% 19.16le""% 16.8lf"16
VE_"% 22.19Le""% 22.19LG"16
VCF_"% 11.8e, % 11.8e""{% 8.4f, % 8.4f}"32
VCD_"% 19.16le, % 19.16le""{% 19.16lE % 19.16lE}"32
VCE_"% 22.19Le, % 22.19Le""{% 22.19Lg % 22.19Lg}"32
VPF_"% 11.8e @% 11.8e""{% 8.4f @% 8.4f}"32
VPD_"% 19.16le @% 19.16le""{% 19.16lE @% 19.16lE}"32
VPE_"% 22.19Le @% 22.19Le""{% 22.19Lg @% 22.19Lg}"32
VI_32-bit: "% 10d"
16-bit: "% 5d"
"0x% 8x"
"0x% 4x"
12
12
VBI_"% 3hd""0x% 2hX"12
VSI_"% 5hd""0x% 4hX"12
VLI_"% 10ld""%08lXh"12
VQI_"% 20.0Lf"16
VU_32-bit: "% 10u"
16-bit "% 5u"
"%04xh"
"%04xh"
12
12
VUB_"% 3hu""0%02ho"12
VUS_"% 5hu""0%04ho"12
VUL_"% 10lu""0%08lO"12

The data type quad is converted into extended before being passed to fprintf (which, at present, does not support quads). This explains why the format string in the VQI_ version tells fprintf to expect a long double. Similarly, byte-sized integers are extended to 16-bit, so that the format specifier has to be for 16-bit numbers.

Error handlingFormat strings longer than the maximum length specified in the above table lead to a program abort with the error message "Invalid Parameter(s)".
The contents of the format string is not checked. So you have to be very careful to specify a format which is valid for the respective data type.
Return valuenone
See alsoVF_setWriteSeparate,   VF_write,   VF_nwrite,   VF_read,   VF_nread

VectorLib Table of Contents  OptiVec home