Nios® V Processor Software Developer Handbook

ID 743810
Date 9/26/2022
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

6.6.1. Standard Input, Standard Output and Standard Error

Using standard input (stdin), standard output (stdout), and standard error (stderr) is the easiest way to implement simple console I/O. The HAL manages stdin, stdout, and stderr behind the scenes, which allows you to send and receive characters through these channels without explicitly managing file descriptors. For example, the HAL directs the output of printf() to standard out, and perror() to standard error. You can associate each channel to a specific hardware device by manipulating BSP settings.
Note: This program sends characters to whatever device is associated with stdout when the program is compiled.

Hello World

#include <stdio.h>
int main ()
{
printf ("Hello world!");
return 0;
}

When using the UNIX-style API, you can use the file descriptors stdin, stdout, and stderr, defined in unistd.h, to access, respectively, the standard in, standard out, and standard error character I/O streams. unistd.h is provided as part of the newlib C library package.