raagasri's Avatar, Join Date: Nov 2009
Newbie Member
#include <stdio.h>
int main(int argc, char** argv)
	char acNamme[10];
	char acPrint[10];
	int iCmp;
	char acName[]= "what is your name";
	scanf("%s \n", &acNamme);
	printf("%s \n", acNamme);
	iCmp = strncmpi(acNamme,acPrint,3);
		printf("Comparison success");
	printf("not success");
why i get an error "undefined reference to 'strncmpi' "

Last edited by shabbir; 3Nov2009 at 09:00.. Reason: Code blocks
xpi0t0s's Avatar, Join Date: Aug 2004
Oops, you forgot to read the posting guidelines. They're really not that difficult to miss and quite easy to read.
murugaperumal's Avatar, Join Date: Feb 2010
Go4Expert Member
Dear Friends,

There is no function like "strncmpi" in C . You should you the stcncmp function.

iCmp = strncmp(acNamme,acPrint,3);
vivekraj's Avatar, Join Date: Feb 2010
Light Poster
There is no such function called strncmpi in C.

If you want to compare the strings with case sensitive.Then,you use strncmp function.

If you want to compare the strings ignoring case.Then,you use strncasecmp function which is similar to strncmp but ignores the case during comparison.
thillai_selvan's Avatar, Join Date: Feb 2010
Go4Expert Member
Are you trying to write your own strncmp function to perform case insensitive comparison?
askmewhy25's Avatar, Join Date: Jan 2010
Go4Expert Member
You can use this header file and save it as strncmpi.h

#include "autocfg.h"
#include "compat/strncmpi.h"
#include <ctype.h>

int strncmpi(const char *a1, const char *a2, unsigned size) {
	char c1, c2;
	/* Want both assignments to happen but a 0 in both to quit, so it's | not || */
	while((size > 0) && (c1=*a1) | (c2=*a2)) {
		if (!c1 || !c2 || /* Unneccesary? */
			(islower(c1) ? toupper(c1) : c1) != (islower(c2) ? toupper(c2) : c2))
			return (c1 - c2);
	return 0;