C puts() function
C library function - puts()
The puts() function is used to write specified string (plus a newline), to the standard output stream. The ending null character is not written.
Syntax:
int puts(const char *str)
Parameters:
Name | Description | Required /Optional |
---|---|---|
str | This is the string to be written. | Required |
Return value
- Upon successful completion, puts() shall return a non-negative number.
- Otherwise, it shall return EOF, shall set an error indicator for the stream, and errno shall be set to indicate the error.
Example: puts() function
#include <stdio.h>
int main()
{
const char *text = "C Programming.";
puts(text);
return 0;
}
Output:
C Programming.
Difference from printf()
- The puts() function prints a newline after the text supplied.
- The puts() function prints the string as it is (% codes are not processed).
C Programming Code Editor:
Previous C Programming: C putchar()
Next C Programming: C perror()
C Programming: Tips of the Day
What is the static function in C ?
Making a function static hides it from other translation units, which helps provide encapsulation.
helper_file.c
int f1(int); /* prototype */ static int f2(int); /* prototype */ int f1(int foo) { return f2(foo); /* ok, f2 is in the same translation unit */ /* (basically same .c file) as f1 */ } int f2(int foo) { return 42 + foo; }
main.c:
int f1(int); /* prototype */ int f2(int); /* prototype */ int main(void) { f1(10); /* ok, f1 is visible to the linker */ f2(12); /* nope, f2 is not visible to the linker */ return 0; }
Ref : https://bit.ly/3CI9ebJ
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook