Redirect Printf Example

Redirect standard I/O to a file

This example illustrates how to redirect standard I/O to a file. The libc library provides freopen() API to redirect all standard IOs (namely - stderr, stdin or stdout). Application first prints launching information at the console and then opens one file to redirect standard output using freopen(). Calling freopen() once more, the user can change the filename during execution. This helps to redirect application printf() messages into a log file.

Download

Click on the following link to download the example: redirectprintf.zip

Click: browse to view the example code.

Design and Implementation

The following sections provide information about the implementation of the example.

Capabilities

The program capabilities are defined in redirectprintf.mmp : CAPABILITY NONE.

Building and Using

To build the example application, go to the redirectprintf\group directory and build the application. The definition for the whole application can be found in the bld.inf file in the group subdirectory of the applications main directory.

The application is simple console based application. It has its own default icon and can be launched from the UI both in the emulator and in the device. The application can be launched by: Executing redirectprintf from eshell. Clicking default icon with display text redirectprintf within the install folder launcher application.