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"头文件中 
函数原型:

  1. 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 字符串替换的更多相关文章

  1. JMeter 内置日期(时间)函数总结

    JMeter 内置日期(时间)函数总结   by:授客 QQ:1033553122 1. 测试环境 apache-jmeter-3.3 下载地址: http://jmeter.apache.org/c ...

  2. Hive 文件格式 & Hive操作(外部表、内部表、区、桶、视图、索引、join用法、内置操作符与函数、复合类型、用户自定义函数UDF、查询优化和权限控制)

    本博文的主要内容如下: Hive文件存储格式 Hive 操作之表操作:创建外.内部表 Hive操作之表操作:表查询 Hive操作之表操作:数据加载 Hive操作之表操作:插入单表.插入多表 Hive语 ...

  3. python 练习题:请利用Python内置的hex()函数把一个整数转换成十六进制表示的字符串

    # -*- coding: utf-8 -*- # 请利用Python内置的hex()函数把一个整数转换成十六进制表示的字符串 n1 = 255 n2 = 1000 print(hex(n1)) pr ...

  4. python(内置高阶函数)

    1.高阶函数介绍: 一个函数可以作为参数传给另外一个函数,或者一个函数的返回值为另外一个函数(若返回值为该函数本身,则为递归),如果满足其一,则为高阶函数. 常见的高阶函数:map().sorted( ...

  5. Python中匿名函数与内置高阶函数详解

    大家好,从今天起早起Python将持续更新由小甜同学从 初学者的角度 学习Python的笔记,其特点就是全文大多由 新手易理解 的 代码与注释及动态演示 .刚入门的读者千万不要错过! 很多人学习pyt ...

  6. classmethod、staticclassmethod内置装饰器函数

    # method 英文是方法的意思 # classmethod 类方法 # 当一个类中的方法中只涉及操作类的静态属性时,此时在逻辑上,我们想要直接通过类名就可以调用这个方法去修改类的静态属性,此时可以 ...

  7. property内置装饰器函数和@name.setter、@name.deleter

    # property # 内置装饰器函数 只在面向对象中使用 # 装饰后效果:将类的方法伪装成属性 # 被property装饰后的方法,不能带除了self外的任何参数 from math import ...

  8. Python 2.7 学习笔记 内置语句、函数、标准库

    使用任何开发语言进行软件开发,都离不开语言提供的内置库(或Api),甚至说内置库的强大及使用是否方便都会影响大家对开发语言的选择. python语言,一样提供了很多内置的功能,可供开发时使用.主要有如 ...

  9. 微信内置浏览器submit函数无效的问题

    在表单提交button被点击时.触发提交函数,代码例如以下: <form id="frm_photo" enctype="multipart/form-data&q ...

随机推荐

  1. Codeforces Round #529 (Div. 3) E. Almost Regular Bracket Sequence (思维)

    Codeforces Round #529 (Div. 3) 题目传送门 题意: 给你由左右括号组成的字符串,问你有多少处括号翻转过来是合法的序列 思路: 这么考虑: 如果是左括号 1)整个序列左括号 ...

  2. Java集合、IO流、线程知识

    一.集合: 1. 集合框架: 1)Collection (1)List:有序的,有索引,元素可重复. (add(index, element).add(index, Collection).remov ...

  3. JavaScript —— 正则表达式元字符

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http ...

  4. [置顶]unity常用开发套件

    维京人骨骼动画制作(Unity 2D Animation资源包使用指南) 维京人骨骼动画制作2(Unity 2D IK资源包使用指南) -------------------------------- ...

  5. spring boot jar的支持

  6. springmvc把对象放到session中

    1:首先把创建的对象放到Map中, @RequestMapping("/testSession")    public String testSession(Map<Stri ...

  7. ES6中模块加载出现的问题

    1.如何在浏览器中import模块 在使用模块加载时不同浏览器有不同的行为 使用 import 加载模块时,需要把script标签的type属性改为module.此时Firefox浏览器支持impor ...

  8. CF 717A Festival Organization——斯特林数+递推求通项+扩域

    题目:http://codeforces.com/contest/717/problem/A 是 BJOI2019 勘破神机 的弱化版. 令 \( g[i] \) 表示长为 i .以 1 结尾的方案数 ...

  9. 状压 DP:[USACO06NOV] Corn Fields,[USACO13NOV] No Change

    [USACO06NOV] Corn Fields (试题来源:Link ) 题目描述 Farmer John has purchased a lush new rectangular pasture ...

  10. js中打地鼠游戏

    <!DOCTYPE html><html lang=""><head> <mata charset = "utf-8" ...