Program to illustrates strncat( ), strnset( ) and strncmp( ) functions


#include <iostream.h>
#include <conio.h>
#include <string.h>
void main()
    {
        char s1[] = "Apple" , s2[] = "mango" , c = 'v';
        int n = 3 , m ;

        puts ("String 1 - ") ;
        puts (s1) ;

        strncat (s1,s2,n) ;
        puts ("Result of strncat( ) - ") ;
        puts (s1) ;

        puts ("Set String 1 - ") ;
        strnset (s1,c,n) ;
        puts (s1) ;

        puts ("String 2 - ") ;
        puts (s2) ;

        n = 4 ;

        m = strncmp (s2,s1,n) ;
        puts ("Result of strncmp( ) - ") ;
        cout<<m ;

        getch ( ) ;
    }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|