Putchar function : Displaying String in C Programming
Syntax :

int putchar(int c);
Way 1 : Taking Character as Parameter
putchar('a') ;  // Displays : a
  1. Individual Character is Given as parameter to this function.
  2. We have to explicitly mention Character.
Way 2 : Taking Variable as Parameter
putchar(a); 
// Display Character Stored in a
  1. Input Parameter is Variable of Type "Character".
  2. This type of putchar() displays character stored in variable.
Way 3 : Displaying Particular Character from Array
putchar(a[0]) ;  
// Display a[0] th element from array
  1. Character Array or String consists of collection of characters.
  2. Like accessing individual array element , characters can be displayed one by one using putchar().
Live Example :
#include< stdio.h>
#include< conio.h>
void main()
{
   char string[] = "This is an example string\n";
   int i=0;
   clrscr();
   while(string[i]!='\0')
   {
     putchar(string[i]);
     i++;
   }
getch();
}

What it Does ?
  1. Display String Character by Character
  2. Header File : stdio.h
  3. Putchar is a macro that outputs a character on stdout.
Related Articles :
  1. How to Input Password in C : Validation of User name
  2. Putchar function >> Displaying String in C
  3. Puts >> Displaying String in C Programming
  4. Printf >> Displaying String in C Programming


Tags / Keywords : | ,

0 comments

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email