6.18.36 puts Function

Put a string to stdout.

Include

<stdio.h>

Prototype

int puts(const char * s);

Argument

s
string to be written

Return Value

Returns a non-negative value if successful; otherwise, returns EOF.

Remarks

The function writes characters to the stream stdout. A newline character is appended. The terminating null character is not written to the stream.

When building with the MPLAB XC8 compiler for PIC MCUs, the puts() function relies on the putch() function being properly defined to direct output to the required peripheral or location. Printing will not work as expected until the putch() stub (found in the pic/sources/c99/common/putch.c of your compiler distribution) is completed. See Example code for 8-bit PIC MCUs for information on defining putch() so that printed text appears in an MPLAB X IDE simulator window.

Example

#include <stdio.h>

int main(void)
{
  char buf[] = "This is text\n";

  puts(buf);
  puts("|");
}

Example Output

This is text

|