惠州有哪些做网站的公司,怎样建移动网站,西安注册公司流程,抖音代运营合同范本免费函数定义#xff1a;char *index(const char *s, int c);头文件#xff1a; #include strings.h函数说明#xff1a;index()用来找出参数s 字符串中第一个出现的参数c 地址#xff0c;然后将该字符出现的地址返回。字符串结束字符(NULL)也视为字符串一部分。返回值…函数定义char *index(const char *s, int c);头文件 #include strings.h函数说明index()用来找出参数s 字符串中第一个出现的参数c 地址然后将该字符出现的地址返回。字符串结束字符(NULL)也视为字符串一部分。返回值如果找到指定的字符则返回该字符所在地址否则返回NULL程序举例#include #include int main(){char *s abcdef123456abcdef;char *p NULL;p index(s, b);printf(%s\n, p);return 0;}执行结果dzlab:~/test/test# ./a.outbcdef123456abcdef相关函数char *rindex(const char *s, int c);函数说明rindex()用来找出参数s 字符串中最后一个出现的参数c 地址然后将该字符出现的地址返回。字符串结束字符(NULL)也视为字符串一部分。程序举例#include #include int main(){char *s abcdef123456abcdef;char *p NULL;p rindex(s, b);printf(%s\n, p);return 0;}执行结果dzlab:~/test/test# ./a.outbcdef扩展部分在查man手册的时候发现头文件是strings.h不是string.h是不是手册错了于是乎百度了一番找到了具体描述结果strings.h头文件是从BSD系UNIX系统继承而来里面定义了一些字符串函数如bzero等。这些函数曾经是posix标准的一部分但是在POSIX.1-2001标准里面这些函数被标记为了遗留函数而不推荐使用。在POSIX.1-2008标准里已经没有这些函数了如下int bcmp(const void *, const void *, size_t); /* 用memcmp替代 */void bcopy(const void *, void *, size_t); /* 用memcpy, memmove替代 */void bzero(void *, size_t); /* 用memset替代 */int ffs(int); /* string.h 中有 */char *index(const char *, int); /* 用strchr替代 */char *rindex(const char *, int); /* 用strrchr替代 */int strcasecmp(const char *, const char *); /* string.h 中有 */int strncasecmp(const char *, const char *, size_t); /* string.h 中有 */这两个头文件都在linux的/usr/include目录下面后者比前者多了一个s一般使用以string.h(没有s)的为主那strings.h(有s)什么时候使用呢打开这个头文件可以看见区别如下/* We dont need and should not read this file if was alreadyread. The one exception being that if __USE_BSD isnt defined, thenthese arent defined in string.h, so we need to define them here. */所以一般使用前者就可以了。