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); ...
随机推荐
- jquery 上传图片即时预览功能
<script type="text/javascript"> jQuery.fn.extend({ uploadPreview: ...
- 51 NOD 1384 全排列(STL 搜索)
1384 全排列 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 给出一个字符串S(可能又重复的字符),按照字典序 ...
- windows下Emacs的安装与配置
1.下载 到这个网址可以下载到Emacs的windows版本:http://ftp.gnu.org/pub/gnu/emacs/windows/ 只需要一个压缩文档,如emacs-23.2-bin-i ...
- HDU 4314 Save the dwarfs (DP) ---转载
题目:传送门. 这个是DP,比赛的时候用贪心写了好久没写出来. 题意: 有n个矮人被困在深度为h的井中,每个矮人都ai(脚到肩膀的高度)和bi(手臂长度), 当存在a1 + a2 + ... + ak ...
- IOS- DocumentInteraction Controllerl的使用
iOS提供了使用其他app预览文件的支持,这就是Document Interaction Controller.此外,iOS也支持文件关联,允许其他程序调用你的app打开某种文件.而且,从4.2开始, ...
- jQuery取复选框值、下拉列表里面的属性值、取单选按钮的属性值、全选按钮、JSON存储、*去空格
1.jquery取复选框的值<!--引入jquery包--> <script src="../jquery-1.11.2.min.js"></scri ...
- August 11th 2016, Week 33rd Thursday
A particular fine spring came around. 转眼又是一番分外明媚的春光. Hey, it is hot outside, sometimes even unbearab ...
- Ionic环境搭建
stepts npm install -g ionic@beta Make sure you have NodeJS installed. Download the installer here or ...
- 三、jQuery--jQuery基础--jQuery基础课程--第12章 jQuery在线聊天室
在线聊天室案例 一.功能简介: 1.用户需要登录后才能进入聊天室交流 2.已无刷新的方式,动态展示交流后的内容和在线人员的基本信息 3.登录后的用户可以提交文字和表情图标 技术重点:利用ajax的无刷 ...
- ListView介绍
原文:http://blog.csdn.net/qingye_love/article/details/13772391?utm_source=tuicool&utm_medium=refer ...