Pages

Get Input From User and Print one word per Line.

Friday 19 April 2013



#include <stdio.h>
#include <conio.h>
#include <string.h>
main()
{
      int tab=0, new_line=0, blank=0, i, j;
      char string[500];
      char ch;
      printf("Enter data. Press \'.\' when complete.\n");
 
      i=0;
      while(ch!='.')
      {
                    ch=getche();
                    string[i]=ch;
                    if(ch==13)
                    {
                              printf("\n");
                              string[i]='\n';
                             
                    }
                    if(ch==32 || ch==9)
                    {
                              string[i]='\n';        
                    }
                    i++;        
      }
      printf("\n");
      for(j=0; j<=i; j++)
      {
               printf("%c", string[j]);      
      }
      getch();  
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *