⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myutils.c

📁 C语言源代码及相关资料
💻 C
字号:
char	lowercase ( char c ){	if ( 'A' <= c && c <= 'Z' ) return (char)(c - 'A' + 'a');	return c;}int		mystrcmpnocase ( char * p, char * q ){char	c;char	d;		if ( p == 0 ) return -1;	if ( q == 0 ) return  1;	do {		c = lowercase ( *p++ );		d = lowercase ( *q++ );		if ( c < d ) return -1;		//	include c == null char		if ( c > d ) return  1;		//	include d == null char	} while  ( c != '\0' || d != '\0' );	return 0;}int		mystrncmpnocase ( char * p, char * q, int n ){char	c;char	d;		if ( p == 0 ) return -1;	if ( q == 0 ) return  1;	do {		c = lowercase ( *p++ );		d = lowercase ( *q++ );		if ( c < d ) return -1;		//	include c == null char		if ( c > d ) return  1;		//	include d == null char		if ( --n <= 0 ) break;	} while  ( c != '\0' || d != '\0' );	return 0;}/*Purpose:	get data of first field in string 'p',	and store data into buffer 'pfield' with the size 'nbytes' + 1;	nbytes for data space and plus one byte for NULL terminating charParameters:	p:		target string to retrieve field data	pfield:	buffer to store first field	nbytes:	space size of pfield - 1 Return:	finally, return the pointer of first byte of the next field or 0, i.e. no field followed*/unsignedchar *	getfield ( unsigned char * p, unsigned char * pfield, int nbytes ){int		i;char	c;	if ( pfield == 0 ) return 0;	//	not valid spaces	*pfield = '\0';	if ( nbytes <= 0 ) return 0;	//	no spaces to store	if ( p == 0      ) return 0;	//	nothing to do	i = 0;	while ( i++ < nbytes )			//	not yet reach to the end of first field	{		c = *p++;					//	get current byte		if ( c == '\0' )			//	reach the end of string 'p'		{			*pfield = '\0';			return 0;				//	no next field followed		}		else if ( c == ',' )		//	reach the end of first field		{			*pfield = '\0';			return p;				//	return pointer of the next byte of ','		}		else		{			*pfield++ = c;			//	store data into buffer 'pfield'		}	}	*pfield = '\0';					//	buffer size less than the first field's one	while ( (c = *p++) )			//	to reach the end of first field	{		if ( c == ',' ) return p;	//	reach the end of first field									//	and return pointer of the next byte of ','	}	return 0;						//	no next field followed}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -