Image

C Language - Structure of C - Reading and Writing String

Reading and writing string

There are two types of string function are available in C language for reading and writing a character.

  • gets()
  • puts()
1.gets();

gets(); By using gets() function we take sequence of character that is string from input device(keyboard).

Syntax: gets(variable_name);
EX: char name[10];
gets(name);
2.puts();

puts(); By using puts() function we print sequence of character that is string to output device(monitor).

Syntax: puts(variable_name);
EX: puts(name);

Example:
#include<stdio.h>
#include<conio.h>
main(){
char string[50];
clrscr();
printf("\nEnter any string ");
gets(string);
printf("\nCharacter String ");
puts(string);
getch();
}