1PUTS(P)                    POSIX Programmer's Manual                   PUTS(P)
2
3
4

NAME

6       puts - put a string on standard output
7

SYNOPSIS

9       #include <stdio.h>
10
11       int puts(const char *s);
12
13

DESCRIPTION

15       The puts() function shall write the string pointed to by s, followed by
16       a <newline>, to the standard output stream stdout. The terminating null
17       byte shall not be written.
18
19       The st_ctime and st_mtime fields of the file shall be marked for update
20       between the successful execution of puts() and the next successful com‐
21       pletion  of a call to fflush() or fclose() on the same stream or a call
22       to exit() or abort().
23

RETURN VALUE

25       Upon successful completion, puts() shall return a non-negative  number.
26       Otherwise,  it  shall  return EOF, shall set an error indicator for the
27       stream,    and errno shall be set to indicate the error.
28

ERRORS

30       Refer to fputc() .
31
32       The following sections are informative.
33

EXAMPLES

35   Printing to Standard Output
36       The following example gets the current time, converts it  to  a  string
37       using localtime() and asctime(), and prints it to standard output using
38       puts(). It then prints the number of minutes to an event for  which  it
39       is waiting.
40
41
42              #include <time.h>
43              #include <stdio.h>
44              ...
45              time_t now;
46              int minutes_to_event;
47              ...
48              time(&now);
49              printf("The time is ");
50              puts(asctime(localtime(&now)));
51              printf("There are %d minutes to the event.\n",
52                  minutes_to_event);
53              ...
54

APPLICATION USAGE

56       The puts() function appends a <newline>, while fputs() does not.
57

RATIONALE

59       None.
60

FUTURE DIRECTIONS

62       None.
63

SEE ALSO

65       fopen()   ,   fputs()  ,  putc()  ,  the  Base  Definitions  volume  of
66       IEEE Std 1003.1-2001, <stdio.h>
67
69       Portions of this text are reprinted and reproduced in  electronic  form
70       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
71       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
72       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
73       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
74       event of any discrepancy between this version and the original IEEE and
75       The Open Group Standard, the original IEEE and The Open Group  Standard
76       is  the  referee document. The original Standard can be obtained online
77       at http://www.opengroup.org/unix/online.html .
78
79
80
81IEEE/The Open Group                  2003                              PUTS(P)
Impressum