strncmpi() string handling functions - C-Tutorial

Latest

Friday, 7 October 2016

strncmpi() string handling functions

C - strncmpi() function:             The general format of strncmpi() function is:

                        Syntax:           strncmpi(string1 , string2 , n);


           
         Where, n is an integer argument.  Function compares atmost n characters of the given two strings without case consideration.

/* EXAMPLE PROGRAM */

#include<string.h>
main()
{
            char str1[50],str2[50];
            clrscr();
            printf("\nEnter string 1:");
            gets(str1);
            printf("\nEnter string 2:");
            gets(str2);
            if((strncmpi(str1,str2,3))==0)
                        printf(“\n Both Are Same”);
            else
                        printf(“\n Both Are Different”);

}

No comments:

Post a Comment