loadrunner中切割字符串
下面函数的作用:
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中切割字符串的更多相关文章
- LoadRunner中截取字符串
LoadRunner中截取字符串 /*strchr和strrchr的区别*/ char *strTest1="citms citms"; char *strTest2,*strTe ...
- shell 从变量中切割字符串
1. 在shell变量中切割字符串 shell中截取字符串的方法有很多中,${expression}一共有9种使用方法.${parameter:-word}${parameter:=word}${pa ...
- 在LoadRunner中转换字符串大小写的C语言函数
在LoadRunner中转换字符串大小写的C语言函数 . loadrunner语言ccharacterstringaction 封装ConvertToXXX函数: //ConvertToUpper f ...
- loadrunner中切割strtok字符串
http://blog.sina.com.cn/s/blog_7ee076050102vamg.html http://www.cnblogs.com/lixiaohui-ambition/archi ...
- 在LoadRunner中进行Base64的编码和解码
<Base64 Encode/Decode for LoadRunner>这篇文章介绍了如何在LoadRunner中对字符串进行Base64的编码和解码: http://ptfrontli ...
- LoadRunner中常用的字符串操作函数
LoadRunner中常用的字符串操作函数有: strcpy(destination_string, source_string); strc ...
- PHP 中使用explode()函数切割字符串为数组
explode()函数的作用:使用一个字符串分割另一个字符串,打散为数组. 例如: 字符串 $pizza = "第1 第2 第3 第4 第5 第6"; 根据空格分割后:$piece ...
- 在LoadRunner中查找和替换字符串
参考<Search & Replace function for LoadRunner>: http://ptfrontline.wordpress.com/2009/03/13/ ...
- LoadRunner中字符串的操作
LoadRunner中字符串的操作 LoadRunner中常用的字符串操作函数有: strcpy(destination_string, source_string); ...
随机推荐
- K3中添加的一条新数据,其在数据库中的位置
最近研究将K3系统与生产管理系统结合起来,减少工作量,但如何确定其各自后台数据库的构成,其对应数据各自位于那张表内,总结了一下: 1.从百度搜索,查看表结构,然后找到目标表 另:K3数据库中单独 ...
- Match:Period(POJ 1961)
Period 题目大意:给定一个字符串,要你找到前缀重复了多少次 思路,就是kmp的next数组的简单应用,不要修正next的距离就好了,直接就可以跳转了 PS:喝了点酒用递归实现除法和取余了...结 ...
- WCF服务与WCF数据服务的区别
问: Hi, I am newbie to wcf programming and a little bit confused between WCF Service and WCF Data Se ...
- SuperIndicator 专做轮播图库,没有之一,支持轮播图无限循环
github地址:https://github.com/hejunlin2013/SuperIndicator SuperIndicator a superindicatorlibray for vi ...
- RecyclerView的万能分割线
效果图: 使用方法: 添加默认分割线:高度为2px,颜色为灰色 mRecyclerView.addItemDecoration(new RecyclerViewDivider(mContext, Li ...
- 9.22 window对象、document对象
一.window对象: 属性(值或者子对象): opener:打开当前窗口的源窗口,如果当前窗口是首次启动浏览器打开的,则opener是null,可以利用这个属性来关闭源窗口 dialogArgume ...
- 第一次点击Div1显示Div2,再次点击Div1的时候又隐藏Div2
要使用Jquery来实现,记得引用Jquery库哦,代码如下: $(document).ready(function(){ $("#ck1").click(function(){ ...
- VS VA助手补丁覆盖目录
以VS2010为例. VA_X.dll 复制到以下文件夹内,覆盖原文件. WinXP系统: %USERPROFILE%\Local Settings\Application Data\Microsof ...
- iOS 开发多线程篇—GCD的常见用法
iOS开发多线程篇—GCD的常见用法 一.延迟执行 1.介绍 iOS常见的延时执行有2种方式 (1)调用NSObject的方法 [self performSelector:@selector(run) ...
- Redis自定义动态字符串(sds)模块(二)
sds模块的具体实现: 1.sdsnewlen 根据参数生成一个sds字符串 sds sdsnewlen(const void *init, size_t initlen) { struct sdsh ...