Print text using string in C


This is a simple C program that reads in a string from the user and prints it back to the console. It uses the following functions:

  • gets: Reads a line of text from the standard input (keyboard) into a string buffer.
  • puts: Writes a null-terminated string to the standard output (console).

The program declares an array of characters named str with a size of 100, which will be used to store the input string. The message "Enter The String:" is displayed, prompting the user to enter a string. The gets function is then used to read the input string from the user and store it in str. Finally, the message "Given String:" is displayed, followed by the puts function, which writes the content of str to the console.

Source Code

#include<stdio.h>
int main()
{
  char str[100];
  printf("\nEnter The String:");
  gets(str);
  printf("\nGiven String:");
  puts(str);
  return 0;
}
To download raw file Click Here

Output

Enter The String: Tutor Joe's
Given String: Tutor Joe's

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C