如果存在,则返回第一次查找到的字节地址,
不存在,则返回空*/
pRetval = strrchr((char*)pSrc, 98);
printf("[%s]-[%d] pRetval = %s \n", __func__, __LINE__, pRetval);
/* 个人理解:在目标字符串中,从字符串开头开始查找对已ASCII码为98的字节,
如果存在,则返回最后一次查找到的字节地址,
不存在,则返回空*/
return 0; } ~4 strcoll 比较字符串
int main (void )
{
/*
* like the strcmp
*/
return 0;
}
~
~
5 strdup
类与字符串拷贝函数,只是需要手动释放返回的字符串地址
int main (void )
{
/* NAME
strdup, strndup - duplicate a string
* SYNOPSIS
#include <string.h>
char *strdup(const char *s);
char *strndup(const char *s, size_t n);
* DESCRIPTION
The strdup() function returns a pointer to a new string which is a duplicate of the string s.
Memory for the new string is obtained with malloc(3), and can be freed with free(3).
The strndup() function is similar, but only copies at most n characters.
If s is longer than n, only n characters are copied, and a terminating null byte ('\0') is added.
* RETURN VALUE
The strdup() function returns a pointer to the duplicated string, or NULL if insufficient memory was available.
*/
const char *pSrc = "Hello, world!";
char *pRetval = strdup( pSrc );
printf("[%s]-[%d] pRetval = %s \n", __func__, __LINE__, pRetval);
/* 复制目标字符串,返回字符串的内存地址需要自己手动释放 */
if( pRetval != NULL )
{
free( pRetval );
pRetval = NULL;
}
pRetval = strndup( pSrc, 4);
/* 复制指定长度目标字符串,返回字符串的内存地址需要自己手动释放 */
printf("[%s]-[%d] pRetval = %s \n", __func__, __LINE__, pRetval);
if( pRetval != NULL )
{
free( pRetval );
pRetval = NULL;
}
return 0;
}
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-29692-5.html
所谓“日本潜艇强于中国”的说法完全是无稽之谈
在这里你说关你鸟事
果断刷机了