Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Writing strings using %s format

Posted By: Adelaide Miller     Category: C Programming     Views: 3609

Writing strings using %s format.

Code for Writing strings using %s format in C Programming

 main()                                                      
   {                                                           
       char  country[15] = "United Kingdom";            

       printf("\n\n");                                         
       printf("*123456789012345*\n");                          
       printf(" --------------- \n");                          
                                                               
       printf("%15s\n", country);                            
       printf("%5s\n", country);                             
       printf("%15.6s\n", country);                          
       printf("%-15.6s\n", country);                         
       printf("%15.0s\n", country);                          
       printf("%.3s\n", country);                            
       printf("%s\n", country);                              
       printf("---------------- \n");                          
   }                                                           


Output                                                      
                                                               
   *123456789012345*                                           
    ------------------
     United Kingdom                                           
    United Kingdom                                           
             United                                           
    United                                                    
                                                             
    Uni
    United Kingdom
  
Share: 


Didn't find what you were looking for? Find more on Writing strings using %s format Or get search suggestion and latest updates.

Adelaide Miller
Adelaide Miller author of Writing strings using %s format is from Frankfurt, Germany.
 
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!