使用 内置函数strtok()函数实现 loadrunner 字符串替换
Action()
{
/* loadrunner 字符串替换 */
char separators[] = "/";
char * token;
char * file_path;
char * file_path_record;
int len_file_path = 0;
extern char * strtok(char * string, const char * delimiters ); // Explicit declaration
int i=0;
file_path= (char *)calloc(200, sizeof(char));
lr_save_string("http://192.168.70.65:8888/group1/M00/00/A0/wKhGQVvo51SAKaaRAAPCOT1ZRgY858.png","return_file_path");
strcat(file_path,lr_eval_string("{return_file_path}"));
token = (char *)strtok(file_path, separators); // Get the first token
if (!token) {
lr_output_message ("No tokens found in string!");
return( -1 );
}
// lr_output_message ("*****%s", token );
len_file_path=200+strlen(token);
file_path= (char *)calloc(len_file_path, sizeof(char));
file_path_record= (char *)calloc(len_file_path, sizeof(char));
while (token != NULL ) { // While valid tokens are returned
strcat(file_path, token);
strcat(file_path_record, token);
if (i==0)
{
lr_output_message("\\\\\\\\\\\\/");
lr_output_message("\\\\/");
lr_output_message(file_path);
strcat(file_path,"\\\\\\\\\\\\/");
strcat(file_path,"\\\\\\\\\\\\/");
strcat(file_path_record,"\\\\/");
strcat(file_path_record,"\\\\/");
lr_output_message(file_path);
}
else if (i==6)
{
strcat(file_path,"");
strcat(file_path_record,"");
}
else
{
strcat(file_path,"\\\\\\\\\\\\/");
strcat(file_path_record,"\\\\/");
}
lr_output_message ("第%d个字符串:%s", i,token );
i+=1;
token = (char *)strtok(NULL, separators); // Get the next token
}
lr_save_string(lr_eval_string(file_path), "param_file_path");
lr_save_string(lr_eval_string(file_path_record), "param_file_path_record");
lr_output_message(lr_eval_string("{param_file_path}"));
lr_output_message(lr_eval_string("{param_file_path_record}"));
return 0;
}
char *strtok( char *strToken, const char *strDelimit );
Strtok()函数详解:
该函数包含在"string.h"头文件中
函数原型:
char* strtok (char* str,constchar* delimiters );
函数功能:
切割字符串,将str切分成一个个子串
函数参数:
str:在第一次被调用的时间str是传入需要被切割字符串的首地址;在后面调用的时间传入NULL。
delimiters:表示切割字符串(字符串中每个字符都会 当作分割符)。
函数返回值:
当s中的字符查找到末尾时,返回NULL;
如果查不到delimiter所标示的字符,则返回当前strtok的字符串的指针。
#include<stdio.h>
#include<string.h>
int main(void)
{
char buf[]="hello@boy@this@is@heima";
char*temp = strtok(buf,"@");
while(temp)
{
printf("%s ",temp);
temp = strtok(NULL,"@");
}
return0;
}
使用 内置函数strtok()函数实现 loadrunner 字符串替换的更多相关文章
- JMeter 内置日期(时间)函数总结
JMeter 内置日期(时间)函数总结 by:授客 QQ:1033553122 1. 测试环境 apache-jmeter-3.3 下载地址: http://jmeter.apache.org/c ...
- Hive 文件格式 & Hive操作(外部表、内部表、区、桶、视图、索引、join用法、内置操作符与函数、复合类型、用户自定义函数UDF、查询优化和权限控制)
本博文的主要内容如下: Hive文件存储格式 Hive 操作之表操作:创建外.内部表 Hive操作之表操作:表查询 Hive操作之表操作:数据加载 Hive操作之表操作:插入单表.插入多表 Hive语 ...
- python 练习题:请利用Python内置的hex()函数把一个整数转换成十六进制表示的字符串
# -*- coding: utf-8 -*- # 请利用Python内置的hex()函数把一个整数转换成十六进制表示的字符串 n1 = 255 n2 = 1000 print(hex(n1)) pr ...
- python(内置高阶函数)
1.高阶函数介绍: 一个函数可以作为参数传给另外一个函数,或者一个函数的返回值为另外一个函数(若返回值为该函数本身,则为递归),如果满足其一,则为高阶函数. 常见的高阶函数:map().sorted( ...
- Python中匿名函数与内置高阶函数详解
大家好,从今天起早起Python将持续更新由小甜同学从 初学者的角度 学习Python的笔记,其特点就是全文大多由 新手易理解 的 代码与注释及动态演示 .刚入门的读者千万不要错过! 很多人学习pyt ...
- classmethod、staticclassmethod内置装饰器函数
# method 英文是方法的意思 # classmethod 类方法 # 当一个类中的方法中只涉及操作类的静态属性时,此时在逻辑上,我们想要直接通过类名就可以调用这个方法去修改类的静态属性,此时可以 ...
- property内置装饰器函数和@name.setter、@name.deleter
# property # 内置装饰器函数 只在面向对象中使用 # 装饰后效果:将类的方法伪装成属性 # 被property装饰后的方法,不能带除了self外的任何参数 from math import ...
- Python 2.7 学习笔记 内置语句、函数、标准库
使用任何开发语言进行软件开发,都离不开语言提供的内置库(或Api),甚至说内置库的强大及使用是否方便都会影响大家对开发语言的选择. python语言,一样提供了很多内置的功能,可供开发时使用.主要有如 ...
- 微信内置浏览器submit函数无效的问题
在表单提交button被点击时.触发提交函数,代码例如以下: <form id="frm_photo" enctype="multipart/form-data&q ...
随机推荐
- POJ 3764 The xor-longest Path (01字典树)
<题目链接> 题目大意: 给定一颗$n$个节点$(n\leq10^5)$,有边权的树,其边权$(0\leq w < 2^{31})$.让你求出这棵树上任意两个节点之间的异或最大值. ...
- day65--mysql数据库--索引、慢日志、分页
---恢复内容开始--- 一.索引 (一)介绍: 数据库中专门用于帮助用户快速查找数据的一种数据结构.类似于字典中的目录,查找字典内容时可以根据目录查找到数据的存放位置吗,然后直接获取. (二)作用: ...
- vue项目build打包后图片路径不对导致图片空白不显示问题解决方法
1.在上篇文章src配置及引入的基础上修改项目配置: 文章链接地址:https://www.cnblogs.com/hsl-shiliang/p/10333022.html. 2.具体配置过程如图: ...
- javaScript的预加载
在有大量图片的页面中,为了避免页面加载完图片还未加载完成,我们通常会使用js的图片预加载. 这是一个预加载的demo: 首先把图片放入到一个类名为imgSrcArr的变量当中: var imgSrcA ...
- 一、asp的写法
一.asp的写法 vs从来都不支持asp,但是可以用vscode写,好多年前写asp的时候,用的是dreamwaver,asp还有创建项目这一说法?调试搭个iis就行了 <html> ...
- (ACM模板)映射map
#include<iostream> #include<cstdio> #include<map> using namespace std; int main() ...
- plsql查询数据中文乱码
在plsql中进行表数据查询的时候,发现查询出来的中文居然显示为乱码,通过查找资料解决该问题. 1.查看数据的编码(语句:select * from v$nls_parameters) 发现显示的语言 ...
- 4412 make menuconfig和make
一.Menuconfig的操作 • Linux编译器通过.config文件确认哪些代码编译进内核,哪些被裁减掉• menuconfig是生成.config的一个工具• 在Linux发展过程中,配置内核 ...
- webbrowser控件显示word文档
参照某网站上的步骤(http://www.kuqin.com/office/20070909/968.html)首先,在Visual Studio中创建一个C#语言的Windows应用程序,然后在左侧 ...
- CF 936C Lock Puzzle——构造
题目:http://codeforces.com/contest/936/problem/C 玩了一个小时,只能想出 5*n 的方法. 经过一番观察?考虑这样构造:已经使得 A 串的一个后缀 = B ...