gtpc2m5iC/C++ Language Support User's Guide

puts-Put String to Standard Output Stream

This function writes a string to the standard output stream.

Format

#include <stdio.h>
int puts(const char *string);

string
The text to be written to stdout.

This function writes the string pointed to by string to the stream pointed to by stdout and appends the new-line character to the output. The terminating null character is not written.

Normal Return

Returns the number of bytes written.

Error Return

If an error occurs, puts returns EOF. If a system write error occurs, the write stops at the point of failure.

Programming Considerations

The puts function has the same restriction as any write operation for a read immediately following a write, or a write immediately following a read. Between a write and a subsequent read, there must be an intervening flush or reposition. Between a read and a subsequent write, there must be an intervening reposition unless an end-of-file (EOF) has been reached.

 The TPF system does not support creating, updating, or deleting files in 1052 or UTIL state. Special files may or may not be writable in 1052 or UTIL state depending on the device driver implementation. 

TARGET(TPF) restrictions

  • The puts function in the TARGET(TPF) library is a limited and nonstandard substitute for the standard puts function. The TARGET(TPF) library has no support for files, stdout, or file redirection.
  • The TARGET(TPF) version of the puts function does not have the same effect as the ISO-C version. Use of both versions in the same application can have results that cannot be predicted.
  • Owing to the large diversity of terminal devices and network support in the TPF system, the installation must code the TARGET(TPF) version of this function to work with its requirements. All programming considerations related to the use of this function, therefore, depend on the manner of implementation.
  • The TARGET(TPF) version of this function requires EBROUT to be set to a valid address. If the entry control block (ECB) that uses this function was created via the entry creation functions (such as credc), the application is responsible for passing the desired value of EBROUT to the ECB that was created.

Examples

The following example writes 'Hello World' to stdout.

#include <stdio.h>
 
int main(void)
{
  if ( puts("Hello World") == EOF )
    printf( "Error in puts\n" );
}

Output

Hello World

Related Information