Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4190608
  • 博文数量: 776
  • 博客积分: 13014
  • 博客等级: 上将
  • 技术积分: 10391
  • 用 户 组: 普通用户
  • 注册时间: 2010-02-22 17:00
文章分类

全部博文(776)

文章存档

2015年(55)

2014年(43)

2013年(147)

2012年(20)

2011年(82)

2010年(429)

分类: C/C++

2010-02-25 11:42:03

// 在字符串"+CMGR: "REC UNREAD", "13776633471",,"10/02/25",11:08:20+3" 中取出 字符串“13776632471”
 
#include
#include
 
int main(void)
{
    char input[256] = "+CMGR: \"REC UNREAD\", \"13776633471\",,\"10/02/25\",11:08:20+3";
    char *p;
 
    /* strtok places a NULL terminator
    in front of the token, if found */
    p = strtok(input, ",");
    if (p)
    {
        printf("%s\n", p);
    }
 
    /* A second call to strtok using a NULL
    as the first parameter returns a pointer
    to the character following the token  */
    p = strtok(NULL, ",");  // 取出字符串: "13776632471"
    if (p)
    {
        printf("%s\n", p);
    }
 
    getch();
    return 0;
}
 
原创,转载请注明地址: wangchenxicool.cublog.cn
 
阅读(1371) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~