Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Program to read a series of words from a terminal using scanf function

Posted By: Joel Evans     Category: C Programming     Views: 39998

Write a program to read a series of words from a terminal using scanf function.

Code for Program to read a series of words from a terminal using scanf function in C Programming

   main( )                                                     
   {                                                           
       char word1[40], word2[40], word3[40], word4[40];        
       printf("Enter text : \n");                              
       scanf("%s %s", word1, word2);                           
       scanf("%s", word3);                                     
       scanf("%s", word4);                                     
       printf("\n");                                           
       printf("word1 = %s\nword2 = %s\n", word1, word2);       
       printf("word3 = %s\nword4 = %s\n", word3, word4);       
   }  
                                                         
Output                                                      
   Enter text :                                                
   Oxford Road, London M17ED                                   
   word1 = Oxford                                              
   word2 = Road,                                               
   word3 = London                                              
   word4 = M17ED                                               
   Enter text :                                                
   Oxford-Road, London-M17ED United Kingdom                    
   word1 = Oxford-Road                                         
   word2 = London-M17ED                                        
   word3 = United                                              
   word4 = Kingdom 
  
Share: 



Joel Evans
Joel Evans author of Program to read a series of words from a terminal using scanf function is from London, United Kingdom.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!