Programmer Guide > Format Strings > C Format Strings for Data Import and Export
  

C Format Strings for Data Import and Export
You can use C format strings in PV-WAVE with any of the functions that begin with the two letters “DC”; this group of functions has been provided to simplify the process of getting your data in and out of PV-WAVE. This new group of I/O functions does not replace the READ, WRITE, and PRINT commands, but does provide an alternative for most I/O situations.
The FORTRAN strings, discussed in an earlier section of this appendix, are the same for either importing or exporting data. The C format strings, however, differ significantly for importing and exporting data. Thus, the following sections discuss C format strings for importing data, and then those for exporting data.
Using C Format Strings for Importing Data
The C format strings for importing data can be different than those for exporting data. The format strings for importing data are made up of conversion specifiers and literal characters (used for pattern matching), separated by a blank space. Each conversion specifier consists of a % followed by a conversion character. Between the % and the conversion character, you can place one of the following:
*An optional number specifying a maximum field width.
*An h if the imported integer is expected to be a short (16 bit) integer, or an l if the imported integer is expected to be a long (32 bit) integer.
 
note
Unlike the C programming language, PV-WAVE does not allow the use of an assignment suppression character, which is used to skip over an unwanted input field.
C-style Conversion Characters for Importing Data shows the C conversion characters that can be used for importing data in PV-WAVE:
 
Table A-7: C-style Conversion Characters for Importing Data  
Conversion Character
How the Data is Imported
c
Transfers character data, one character at a time.
e, f, g
Transfers double-precision floating-point data with optional sign, decimal point, and exponent. Precede with l for double-precision.
d or i
Precede with l for long integers on 64-bit UNIX, ll for 64-bit integers on 64-bit Windows.
o
Transfers octal data.
x
Transfers hexadecimal data.
u
Transfers unsigned integer data.
s
Transfers character strings.
%
Used in pattern matching to produce a literal % symbol. No conversion occurs.
Using C Format Strings for Exporting Data
The C format strings for exporting data can be different than those for importing data. The format string for exporting data is made up of ordinary characters and conversion specifications, which cause conversion and printing of the next value in the file. Each conversion specification consists of a % followed by a conversion character. Between the % and the conversion character, you may place, in order:
*A minus sign (–) to left justify the exported values.
*A number to specify the minimum field width.
*A period separating the field width number from the precision number.
*A number to specify the precision, or the maximum number of characters to be printed from a string, or the number of digits after the decimal point of a floating point value, or the minimum number of digits for an integer.
*An h if exported integer is a short, or an l if exported integer is a long.
The following table shows the C conversion characters that can be used for exporting data in PV-WAVE:
 
Table A-8: C-style Conversion Characters for Exporting Data
Conversion Character
How the Data is Exported
c
Transfers character data, one character at a time.
e or E
Transfers double-precision floating-point data using scientific (exponential) notation. Use the form [–]m.dddddd e ± xx or
[–]m.dddddd ± Exx, where number of d’s is given by the precision.
f
Transfers double-precision floating point data in the form
[–]m.dddddd, where the number of d’s is given by the precision. Precede with l for double-precision.
g or G
Uses %e or %f format, depending on the magnitude of the value being processed.
d or i
Precede with l for long integers on 64-bit UNIX, ll for 64-bit integers on 64-bit Windows.
o
Transfers octal data.
x or X
Transfers hexadecimal data.
u
Transfers unsigned integer data.
s
Transfers character strings.
%
Transfers a literal % symbol. No conversion occurs.

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.