Puts() Function In C Language With Example

Home » C programs » C stdio.h library functions programs

puts() function in C language with Example

Here, we are going to learn about the puts() function of library function stdio.h in C language with its syntax, example. Submitted by Souvik Saha, on February 22, 2019

puts() function in C

The puts() function is defined in the <stdio.h> header file.

Prototype:

int puts(const char *string);

Parameters: const char *string

Return type: int

Use of function:

Through the puts() function, we write the string to the output stream stdout which are stored into the character array until it encounters the newline character. The prototype of the function puts() is int puts(const char *string);

Here string is the array of characters which are written to the stream. It returns a non-negative value for the successful operation and EOF for failure.

puts() example in C

#include <stdio.h> int main() { char ch[100]; printf("Enter any string\n"); //get the string gets(ch); printf("\nThe string is - "); //print the string puts(ch); return 0; }

Output

puts() example in C language

C stdio.h Library Functions Programs »

gets() function of stdio.h in C putc() function of stdio.h in C

Related Programs

  • printf() function in C language with Example
  • perror() function of stdio.h in C
  • puts() and putchar() functions of stdio.h in C
  • gets() function of stdio.h in C
  • putc() function of stdio.h in C
  • fgets() function of stdio.h in C
  • fscanf() function of stdio.h in C
  • fopen() function in C language with Example
  • freopen() function in C language with Example
  • fclose() function in C language with Example
  • feof() function in C language with Example
  • ferror() function in C language with Example
  • fgetc() function in C language with Example
  • putc function in C language with Example
  • fputc function in C language with Example
  • fflush() function in C language with Example
  • fgetpos() function in C language with Example
  • fprintf() function in C language with Example
  • fputs() function in C language with Example
  • fread() function in C language with Example
  • fseek() function in C language with Example
  • fsetpos() function in C language with Example
  • ftell() function in C language with Example
  • fwrite() function in C language with Example
  • getc() function in C language with Example
  • snprintf() function in C language with Example
  • getchar() function in C language with Example
  • putchar() function in C language with Example
  • remove() function in C language with Example
  • rename() function in C language with Example
  • rewind() function in C language with Example
Advertisement Advertisement

Comments and Discussions!

Load comments ↻

Tag » What Is Puts In C