C Standard Libraries C++

fwprintf()

Declaration

int fwprintf(FILE* qpStream, const wchar_t* kwpFormatString, ...);

Description

This function outputs the formatted wide-character string "kcpFormatString" to the output stream "qpStream." If successful, the function returns the number of characters output. Otherwise, the function returns a negative value to indicate an error. Formatting is performed exactly as it is for printf. The function returns the number of wide characters written, if successful. Otherwise, it returns a negative value to indicate an error.

Input File

fwprintf() Input File

Output File

fwprintf() Output File

Example

#include <iostream>
#include <cwchar>

int main()
{
    using namespace std;
    char* cpFileName = "XoaX.txt";
    FILE* qpFile = fopen(cpFileName, "a");

    // Check that the file could be opened
    if (!qpFile) {
        cout << "Could not open the file!" << endl;
        return 1;
    }

    // Output Pi in decimal fixed point format with two
    // digits after the decimal point.
    int iReturn = fwprintf(qpFile, L"\nPi = %.2f", 3.14159);
    // Check whether the write was successful.
    if (iReturn < 0) {
        cout << "Write error!" << endl;
    }
    fclose(qpFile);
    return 0;
}

Output

fwprintf() Output
 

© 2007–2022 XoaX.net LLC. All rights reserved.