C++ Puts() - C++ Standard Library - Programiz
Maybe your like
Become a certified C++ programmer.
ENROLLPopular Tutorials
C++ if...else Statement C++ for Loop Arrays in C++ Strings in C++ C++ Class & Objects Start Learning C++Popular Examples
Create a simple calculator Check prime number Print the Fibonacci sequence Check if a number is palindrome or not Program to multiply matrix Explore C++ ExamplesReference Materials
iostream cmath cstring ctime View allCreated with over a decade of experience.
- Learn
- Practice
- Compete
Certification Courses
Created with over a decade of experience and thousands of feedback.
Learn Python Learn HTML Learn JavaScript Learn SQL Learn DSA View all Courses onBecome a certified C++ programmer.
Try Programiz PRO!Popular Tutorials
C++ if...else Statement C++ for Loop Arrays in C++ Strings in C++ C++ Class & Objects Start Learning C++ All C++ TutorialsReference Materials
iostream cmath cstring ctime View all Python JavaScript C C++ Java R KotlinBecome a certified C++ programmer.
Try Programiz PRO!Popular Examples
Create a simple calculator Check prime number Print the Fibonacci sequence Check if a number is palindrome or not Program to multiply matrix All C++ Examples<cstdio> Functions
- C++ getc()
- C++ fseek()
- C++ freopen()
- C++ fflush()
- C++ fwrite()
- C++ fread()
- C++ puts()
- C++ putchar()
- C++ gets()
- C++ getchar()
- C++ fgets()
- C++ fgetc()
- C++ sscanf()
- C++ sprintf()
- C++ snprintf()
- C++ scanf
- C++ printf()
- C++ fscanf()
- C++ fprintf()
- C++ fopen()
- C++ tmpfile()
- C++ rename()
- C++ remove()
C++ Tutorials
- C++ putchar()
- C++ fgets()
- C++ gets()
- C++ fgetc()
- C++ fflush()
- C++ tmpfile()
puts() prototype
int puts(const char *str);The puts() function takes a null-terminated string str as its argument and writes it to stdout. The terminating null character '\0' is not written but it adds a newline character '\n' after writing the string.
The main difference between fputs() and puts() is the puts() function appends a newline character to the output, while fputs() function does not.
It is defined in <cstdio> header file.
puts() Parameters
str: The string to be written.
puts() Return value
On success, the puts() function returns a non-negative integer. On failure it returns EOF and sets the error indicator on stdout.
Example: How puts() function works
#include <cstdio> int main() { char str1[] = "Happy New Year"; char str2[] = "Happy Birthday"; puts(str1); /* Printed on new line since '/n' is added */ puts(str2); return 0; }When you run the program, the output will be:
Happy New Year Happy BirthdayAlso Read:
- C++ gets()
Sorry about that.
How can we improve it? Feedback * Leave this field blankYour builder path starts here. Builders don't just know how to code, they create solutions that matter.
Escape tutorial hell and ship real projects.
Try Programiz PRO- Real-World Projects
- On-Demand Learning
- AI Mentor
- Builder Community
Related Library Functions
C++ Library Function
C++ remove()
C++ Library Function
C++ rename()
C++ Library Function
C++ tmpfile()
C++ Library Function
C++ fopen()
Tag » What Is Puts In C
-
Using The Puts() Function In C/C++ - DigitalOcean
-
What Is Puts In C?
-
C Library Function - Puts() - Tutorialspoint
-
C Gets() And Puts() Functions - Javatpoint
-
Puts Function In C - Linux Hint
-
Puts() Function In C | C File Handling - Fresh2Refresh
-
C Language: Puts Function (Write String) - TechOnTheNet
-
Puts() — Write A String - IBM
-
Puts() Library Function With Examples - CodeSansar
-
Puts() Vs Printf() For Printing A String - GeeksforGeeks
-
Learn The Examples Of C Puts() Function - EduCBA
-
C Gets() & Puts() - W3schools.blog
-
[C언어/C++] Gets, Puts 문자열 입출력 함수에 대해서. - 개발자 지망생
-
Puts() Function In C Language With Example