使用 内置函数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 ...
随机推荐
- python 模块和包深度学习理解
python 模块和包 简单说相当于命名空间 1,python 模块 python模块就是一个文件,里面有函数,变量等 import 模块 模块.方法 from 模块 import fu ...
- Windows系统时间会偶尔自动回拨吗?
为什么80%的码农都做不了架构师?->>> Spring boot 项目 通过日志记录插入sql操作用时 long start2 = System.currentTimeMi ...
- HR面试总结
求职面试HR最欣赏的自我介绍 2015-02-25 来源:www.cnrencai.com 浏览:391 明明很有能力的你,在面试中却不能发挥出色?来看看是不是自我介绍环节出了问题. 回答面试题目 ...
- 修改DbVisualizer的默认快捷键 .
修改SQL提示的步骤如下:1, 编辑dbvis.jar包下的dbvis-actions.xml文件(解压或直接修改)2, 找到以下的代码<actionidref="show-auto- ...
- python 异常处理【转载】
什么是异常?异常即是一个事件,该事件会在程序执行过程中发生,影响了程序的正常执行.一般情况下,在Python无法正常处理程序时就会发生一个异常.异常是Python对象,表示一个错误.当Python脚本 ...
- 一、AJAX
一. (function ($) { //1.得到$.ajax的对象 var _ajax = $.ajax; $.ajax = function (options) { //2.每次调用发送ajax请 ...
- MySQL04-- 版本区别及管理
目录 MySQL版本区别及管理 一.MySQL5.6与MySQL5.7安装的区别 二.MySQL用户权限管理 三.MySQL连接管理 四.MySQL启动关闭流程 五.MySQL实例初始化配置 六.My ...
- Spark- Spark从SFTP中读取zip压缩文件数据做计算
我们遇到个特别的需求,一个数据接入的流程跑的太慢,需要升级为用大数据方式去处理,提高效率. 数据: 数据csv文件用Zip 压缩后放置在SFTP中 数据来源: SFTP 数据操作: 文件和它的压缩包一 ...
- runltp出现问题 [
runltp 623行: if [ "$?" == "0" ]; then 对[解析出了问题. 我灵机一动,是不是sh的问题. which sh /bin/sh ...
- python搭建服务,传输文件
一.进入需要共享的文件目录 #cd /home #python -m SimpleHTTPServer 二.浏览器访问资源 再浏览器地址栏输入: 服务器IP:8000 如图: