Put a string to stdout
.
Include
<stdio.h>
Prototype
int puts(const char *s);
Argument
s
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.
This function relies on
the putch
function to determine the destination of the standard output
stream. A putch
function must be written for each project that uses
printf
, and the project must include code that initializes any
peripherals used by this routine. A stub for putch
can be found in the
sources directory of the compiler. Ensure the source code for your
putch
added to your project once it is complete. An example
putch
function that prints to a USART might be similar to:
void putch(char data)
{
while( ! TXIF)
continue;
TXREG = data;
}
Example
#include <stdio.h>
int main(void)
{
char buf[] = "This is text\n";
puts(buf);
puts("|");
}
Example Output
This is text
|