How to Print a String in C?
How to Print a String in C?
  • Post author:
  • Reading time:1 mins read
  • Post category:C Programs

C Program to Print a String Entered by the User

#include <stdio.h>
int main()
  char name[20]; // Character array
  printf("\n\tC Program to Print a string");
  printf("\n\tEnter a string to print\n\t");
  printf("\tEntered string is: %s\n\n", name);
  return 0;


C program to print a string

Code Explanation

First, declare a string type variable. Then using printf() function print “Enter a string to print”. Then using scanf() function read the string inputted by the user and store it in the variable previously declared. Then print the string using printf() function.

People Also Ask

How strings are read and printed?

First take a string as input from the user by scanf() function and store it in a character array. Then using printf() function print the string on console.