[Contents]
[Prev] [Next] [Limbo Basics] [Limbo Programming] [Language Definition]

Formatted Output

The function for writing to standard output is the print function in the System module. Like C's printf function, it provides formatted output through the use of fomat verbs.

For example:

	sys->print("Hello, %s!\n", hd (tl argv));

This uses the %s format verb to print the data contained in the head of the argv list (which is a string), in addition to printing the literal string. For example:

	Hello, Inferno!

To direct the output to a device other than standard output, use the fprint function. This requires an additional parameter, an open FD. For example, to print to standard error, use the fildes function to obtain:

	stderr := sys->fildes(2);									# get the FD for stderr
	...
	sys->fprint(stderr, "error: %s\n", msg);



[Contents]
[Prev] [Next] [Limbo Basics] [Limbo Programming] [Language Definition]

Copyright © 1998, Lucent Technologies, Inc. All rights reserved.