puts() in C: Usage & Syntax Guide
The puts function in C language is used to display a string on the screen and automatically move to the next line.
The prototype of the puts function is:
int puts(const char* str);
The parameter str is a pointer to a string terminated by null.
This function will output the string “str” to the standard output device, usually the screen, and automatically append a newline at the end. The function returns a non-negative integer value to indicate success, or returns EOF (-1) if an error occurs.
Here is an example of using the puts function:
#include <stdio.h>
int main() {
char str[] = "Hello, World!";
puts(str);
return 0;
}
Output:
Hello, World!
Note that the puts function can only be used to output strings and cannot be used to output other types of data. If you need to output other types of data, you should use another function such as the printf function.