- A virus
1859679fcd4c1a05a4b54fe6e9327dca

Post Top Ad

demo-image
Share This
Responsive Ads Here

c program to copy one string to another and count the number of characters copied

program: 

main( )                                                     
   {                                                           
       char  string1[80], string2[80];                         
       int   i;                                                
                                                               
       printf("Enter a string \n");                            
       printf("?");                                            
                                                               
       scanf("%s", string2);                                   
                                                               
       for( i=0 ; string2[i] != '\0'; i++)                     
          string1[i] = string2[i];                             
                                                               
       string1[i] = '\0';                                      
                                                               
       printf("\n");                                           
       printf("%s\n", string1);                                
       printf("Number of characters = %d\n", i );              
   }
 
Output:                                                      
                                                               
   Enter a string                                              
   ?Manchester                                                 
   Manchester                                                  
   Number of characters = 10                                   
   Enter a string                                              
   ?Westminster                                                
   Westminster                                                 
   Number of characters = 11 
 

Comment Using!!

1 comment:

  1. blogger_logo_round_35

    This C program efficiently copies one string to another while counting the characters copied, enhancing your string manipulation skills! Just like subtitleedit improves gaming performance, mastering these fundamental coding techniques will elevate your programming expertise!

    ReplyDelete

Post Bottom Ad

Pages