使用 内置函数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 ...
随机推荐
- bzoj2396 神奇的矩阵(随机化)
Time Limit: 5 Sec Memory Limit: 512 MB 给出三个行数和列数均为N的矩阵A.B.C,判断A*B=C是否成立. 题目可能包含若干组数据. 对于每组数据,第一行 ...
- 专题:性能调优之工具---perf
1. Linux Perf简介 1.1 Perf是什么 Perf 是内置于Linux 内核源码树中的性能剖析(profiling)工具.它基于事件采样原理,以性能事件为基础,支持针对处理器相关性能指标 ...
- ModbusTcp踩得坑
单元标识符在MODBUS或MODBUS+串行链路子网中对设备进行寻址时,这个域是用于路由的目的.在这种情况下,“Unit Identifier”携带一个远端设备的MODBUS从站地址:- 如果MODB ...
- JS 逻辑非!简单总结
!"" true!"aaa" false""==false true ...
- 2018-10-11-WPF-拖动滚动
title author date CreateTime categories WPF 拖动滚动 lindexi 2018-10-11 14:10:41 +0800 2018-2-13 17:23:3 ...
- linux内存子系统调优
- RPC_简洁版
1.定义服务接口 public interface RpcService { int printHello(int msg); } 2.定义服务接口实现类 public class RpcInterf ...
- join()、split()
join()用于把数组转化为字符串 var arr=['hello','world','kugou']; document.write(arr.join(''));//helloworldkugou ...
- HTTP: 状态码200~505说明
HTTP状态码(HTTP Status Code) 一些常见的状态码为: 200 - 服务器成功返回网页 404 - 请求的网页不存在 503 - 服务不可用 所有状态解释: 1xx(临时响应) 表示 ...
- Quartz.Net 任务调度之时间策略(4)
在复杂的业务逻辑中,cron可以灵活的制定时间策略 先说使用方法 ITrigger trigger = TriggerBuilder.Create() .WithIdentity("trig ...