下面函数的作用:

http://blog.csdn.net/hgj125073/article/details/8447605

通过-与: 字符切割字符串,即-与:字符已经被\0 字符取代

	char s[] = "ab-cd : ef;gh :i-jkl;mnop;qrs-tu: vwx-y;z";

	char *delim = "-: "; 

	char *p; 

	lr_output_message("%s ", strtok(s, delim));

	while((p = (char *)strtok(NULL, delim)))

	lr_output_message("%s ", p);

//	lr_output_message("\n");

char *strtok(char *s, 
const char *delim);
#include<string.h>
分解字符串为一组字符串。s为要分解的字符串,delim为分隔符字符串。
strtok()用来将字符串分割成一个个片段。参数s指向欲分割的字符串,参数delim则为分割字符串中包含的所有字符。当strtok()在参数s的字符串中发现参数delim中包涵的分割字符时,则会将该字符改为\0 
字符。在第一次调用时,strtok()必需给予参数s字符串,往后的调用则将参数s设置成NULL。每次调用成功则返回指向被分割出片段的指针。
s开头开始的一个个被分割的串。当没有被分割的串时则返回NULL。所有delim中包含的字符都会被滤掉,并将被滤掉的地方设为一处分割的节点。
DEMO:MSDN上的 char string[] = "A string\tof ,,tokens\nand some  more tokens";
char seps[]   = " ,\t\n";
char *token;
int main(void)
{
printf( "Tokens:\n" );
token = strtok( string, seps );
while(token !=NULL)
{
printf("%s\n",token);
token=strtok(NULL,seps);
}
getch();
return 0;
}   int main(void)
{
char input[16]="abc,d,yuwen";
char *p;
p=strtok(input,",");
if (p)
{
printf("%s\n",p);
}
p=strtok(NULL,",");
if (p)
{
printf("%s\n",p);
}
getch();
return 0;
}      char str[] = "now # is the time for all # good men to come to the # aid of their country";      char delims[] = "#";     char *result = NULL;     result = (char *)strtok( str, delims );    while( result != NULL ) {      lr_output_message( "result is \"%s\"\n", result ); //    lr_output_message( "result is:%s", result );    result = (char *)strtok( NULL, delims );       }

loadrunner中切割字符串的更多相关文章

  1. LoadRunner中截取字符串

    LoadRunner中截取字符串 /*strchr和strrchr的区别*/ char *strTest1="citms citms"; char *strTest2,*strTe ...

  2. shell 从变量中切割字符串

    1. 在shell变量中切割字符串 shell中截取字符串的方法有很多中,${expression}一共有9种使用方法.${parameter:-word}${parameter:=word}${pa ...

  3. 在LoadRunner中转换字符串大小写的C语言函数

    在LoadRunner中转换字符串大小写的C语言函数 . loadrunner语言ccharacterstringaction 封装ConvertToXXX函数: //ConvertToUpper f ...

  4. loadrunner中切割strtok字符串

    http://blog.sina.com.cn/s/blog_7ee076050102vamg.html http://www.cnblogs.com/lixiaohui-ambition/archi ...

  5. 在LoadRunner中进行Base64的编码和解码

    <Base64 Encode/Decode for LoadRunner>这篇文章介绍了如何在LoadRunner中对字符串进行Base64的编码和解码: http://ptfrontli ...

  6. LoadRunner中常用的字符串操作函数

    LoadRunner中常用的字符串操作函数有:                strcpy(destination_string, source_string);               strc ...

  7. PHP 中使用explode()函数切割字符串为数组

    explode()函数的作用:使用一个字符串分割另一个字符串,打散为数组. 例如: 字符串 $pizza = "第1 第2 第3 第4 第5 第6"; 根据空格分割后:$piece ...

  8. 在LoadRunner中查找和替换字符串

    参考<Search & Replace function for LoadRunner>: http://ptfrontline.wordpress.com/2009/03/13/ ...

  9. LoadRunner中字符串的操作

    LoadRunner中字符串的操作 LoadRunner中常用的字符串操作函数有:                strcpy(destination_string, source_string); ...

随机推荐

  1. Java中的try,catch(Exception e),finally及return执行顺序

    结论: ①就算之前return,finally也会执行 ②finally的计算结果不影响之前的return值 ③finally的return值一定是最后的返回结果,因此将return放入finally ...

  2. Java for LeetCode 223 Rectangle Area

    Find the total area covered by two rectilinear rectangles in a 2D plane. Each rectangle is defined b ...

  3. javax.transaction.xa.XAException: java.sql.SQLException: 无法创建 XA 控制连接。错误: 未能找到存储过程 'master..xp_sqljdbc_xa_init'

    配置JTA SQL Server XADataSource参考:https://msdn.microsoft.com/zh-cn/library/aa342335.aspx 使用 JDBC 驱动程序 ...

  4. mybatis延迟加载

    配置完成后可能会报错Cannot enable lazy loading because CGLIB is not available. Add CGLIB to your classpath 是由于 ...

  5. 【leetcode】Number of 1 Bits (easy)

    做太多遍了,秒杀. class Solution { public: int hammingWeight(uint32_t n) { ; ), num++); return num; } };

  6. 【leetcode】atoi (hard) ★

    虽然题目中说是easy, 但是我提交了10遍才过,就算hard吧. 主要是很多情况我都没有考虑到.并且有的时候我的规则和答案中的规则不同. 答案的规则: 1.前导空格全部跳过  “      123” ...

  7. iOS 中CoreData的简单使用

    原文链接:http://www.jianshu.com/p/4411f507dd9f 介绍:本文介绍的CoreData不在AppDelegate中创建,在程序中新建工程使用,即创建本地数据库,缓存数据 ...

  8. 60. Permutation Sequence

    题目: The set [1,2,3,…,n] contains a total of n! unique permutations. By listing and labeling all of t ...

  9. Java发送邮件初窥

    一.背景 最近朋友的公司有用到这个功能,之前对这一块也不是很熟悉,就和他一起解决出现的异常的同时,也初窥一下使用Apache Common Email组件进行邮件发送. 二.Java发送邮件的注意事项 ...

  10. ASP.NET SignalR 与 LayIM2.0 配合轻松实现Web聊天室(零) 前言

    前端时间听一个技术朋友说 LayIM 2.0 发布了,听到这个消息抓紧去官网看了一下.(http://layim.layui.com/)哎呀呀,还要购买授权[大家支持一下哦],果断买了企业版,喜欢钻研 ...