strtok()     字符串分割函数
strstr()     字符串查找函数

范例
#include <string.h>
main()
{
    char * s = "012345678901234567890123456789";
    char *p;
    p = strstr(s, "901");
    printf("%s\n", p);
}

执行结果:
9.01E+21

strspn()     字符查找函数
strrchr()     定位字符串中最后出现的指定字符
strpbrk()     定位字符串中第一个出现的指定字符
strncpy()     复制字符串
strncat()     字符串连接函数
strncasecmp()     字符串比较函数(忽略大小写)
strlen()     字符串长度计算函数
strdup()     复制字符串
strcspn()     查找字符串

范例
#include <string.h>
main()
{
    char *str = "Linux was first developed for 386/486-based pcs. ";
    printf("%d\n", strcspn(str, " "));
    printf("%d\n", strcspn(str, "/-"));
    printf("%d\n", strcspn(str, "1234567890"));
}

执行结果:
5 //只计算到" "的出现, 所以返回"Linux"的长度
33 //计算到出现"/"或"-", 所以返回到"6"的长度
30 // 计算到出现数字字符为止, 所以返回"3"出现前的长度

strcpy()     复制字符串
strcoll()     字符串比较函数(按字符排列次序)
strcmp()     字符串比较函数(比较字符串)
strchr()     字符串查找函数(返回首次出现字符的位置)

#include <string.h>
main()
{
    char *s = "0123456789012345678901234567890";
    char *p;
    p = strchr(s, '5');
    printf("%s\n", p);
}

执行结果:
5.68E+25

strcat()     连接字符串
strcasecmp()     字符串比较函数(忽略大小写比较字符串)
rindex()     字符串查找函数(返回最后一次出现的位置)
index()     字符串查找函数(返回首次出现的位置)
toupper()     字符串转换函数(小写转大写)
tolower()     字符串转换函数(大写转小写)
toascii()     将整数转换成合法的ASCII码字符
strtoul()     将字符串转换成无符号长整型数
strtol()     将字符串转换成长整型数
strtod()     将字符串转换成浮点数
gcvt()     将浮点型数转换为字符串(四舍五入)
atol()     将字符串转换成长整型数
atoi()     将字符串转换成整型数
atof()     将字符串转换成浮点型数

sscanf(argv[i], "%ld", &junction_count);

sscanf( dtm, "%s %s %d  %d", weekday, month, &day, &year );

sprintf(str, "Value of Pi = %f", M_PI);

C语言字符串函数的更多相关文章

  1. 13-C语言字符串函数库

    目录: 一.C语言字符串函数库 二.用命令行输入参数 回到顶部 一.C语言字符串函数库 1 #include <string.h> 2 字符串复制 strcpy(参数1,参数2); 参数1 ...

  2. C语言字符串函数大全

    C语言字符串函数大全 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include ...

  3. C语言-字符串函数的实现(一)之strlen

    C语言中的字符串函数有如下这些 获取字符串长度 strlen 长度不受限制的字符串函数 strcpy strcat strcmp 长度受限制的字符串函数 strncpy strncat strncmp ...

  4. C语言-字符串函数的实现(五)之strstr

    C语言中的字符串函数有如下这些 获取字符串长度 strlen 长度不受限制的字符串函数 strcpy strcat strcmp 长度受限制的字符串函数 strncpy strncat strncmp ...

  5. C语言-字符串函数的实现(二)之strcpy

    C语言中的字符串函数有如下这些 获取字符串长度 strlen 长度不受限制的字符串函数 strcpy strcat strcmp 长度受限制的字符串函数 strncpy strncat strncmp ...

  6. C语言字符串函数例子程序大全 – string相关

    关于字符串函数的应用细则,例子程序 – jerny 函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source) ...

  7. 关于C语言字符串函数使用的一点心得

    就字符串的拼接函数为例strcat. 原型:extern char *strcat(char *dest,char *src);用法:#include <string.h> 功能:把src ...

  8. c语言字符串函数大全(转)

    函数名: stpcpy 功 能: 拷贝一个字符串到另一个 用 法: char *stpcpy(char *destin, char *source); 程序例: #include <stdio. ...

  9. 07 --C语言字符串函数

    1)字符串操作  复制 strcpy(p, p1)      复制字符串 strncpy(p, p1, n)  复制指定长度字符串 strdup(char *str)      将串拷贝到新建的位置处 ...

随机推荐

  1. C# Json数据反序列化为Dictionary并根据关键字获取指定值

    Json数据: { "dataSet": { "header": { "returnCode": "0", " ...

  2. RHEL 7.2 安装Oracle XE-11.2.0

    轻量快捷版本,适合开发 0. /etc/hosts 添加 本机hostname # hostnamepromote.cache-dns.local # cat /etc/hosts127.0.0.1 ...

  3. dbt

    Procedure Relocate(s : state; b : base_index) { Move base for state s to a new place beginning at b ...

  4. 設定 Bootstrap/SASS/Bower/gulp (Windows平台)

    請注意:在進行以下步驟前,你會需要先安裝git,可以參考這篇 git安裝教學 前言 時至今日,幾乎每個人都在討論bootstrap.less 或 sass.我們知道它們是比較新的前端技術,而且有開始愈 ...

  5. C#快速学习笔记(译)

    下面是通过代码快速学习C#的例子. 1.学习任何语言都必定会学到的hello,world! using System; public class HelloWorld { public static ...

  6. 【转】#ifdef __cplusplus深度剖析

    原文:http://bbs.ednchina.com/BLOG_ARTICLE_251752.HTM 时常在cpp的代码之中看到这样的代码:     #ifdef __cplusplus extern ...

  7. 2014年辛星完全解读Javascript第四节 流程控制语句

    上一节我们介绍了函数,本小节我们介绍一下流程控制语句,对于任何一门编程语言来说,流程控制都是非常重要的,也就是我们常说的顺序结构.选择结构和循环结构. ************选择结构******** ...

  8. mac 下 sphinx + mysql + php 实现全文搜索(xampp)(3)sphinx 的配置项解析

    source:数据的来源,数据是从什么地方来的. index:索引,当有数据源之后,从数据源处构建索引.索引实际上就是相当于一个字典检索.有了整本字典内容以后,才会有字典检索. searchd:提供搜 ...

  9. NET Reflector 8 使用

    一,把杀毒软件停掉 二,把原机器上的 Reflector 文件删除 三,找到C:\Users\Administrator\AppData\Local\Red Gate这个目录,将里面的东西删除 四,v ...

  10. springMVC数据封装成POJO

    springMVC把前台的数据封装为POJO与struts2的封装形式不同.struts2需要在控制器声明需封装的POJO,而springMVC不需要任何准备工作,只需在相应的方法的参数中加上需封装的 ...