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;
}

最新文章

  1. JSBinding / Testing
  2. javascript中的链表结构
  3. Spring基本概念
  4. oracle 常用视图和表
  5. 动态SQL之标签
  6. Labview实现幅度信号调制(AM)
  7. Re-enable Alcatraz on Xcode 6.3.2 or newer
  8. StoryBoard 的使用
  9. 还是回文(dp)
  10. 微信小程序异步处理
  11. pandas(二)
  12. [Android][Framework] 添加系统服务
  13. Ubuntu 16.04安装JDK(转载)
  14. 洛谷P4145 上帝造题的⑦minutes ②
  15. topcoder srm 305 div1
  16. 2018.08.16 洛谷P1437 [HNOI2004]敲砖块(二维dp)
  17. 不会几个框架,都不好意思说搞过前端: Vue.js - 60分钟快速入门
  18. 常用函数-filter、map、reduce、sorted
  19. 深入理解ajax系列第九篇
  20. UML中的组合、聚合、关联、继承、实现、依赖

热门文章

  1. Mybatis-技术专区-中的条件查询createCriteria example里面的条件
  2. 剑指offer学习--初级c++面试题
  3. Mata标签,og标签
  4. 脚本_检测mysql存活状态
  5. mysql授予权限
  6. java 字符串的截取、转换、分割
  7. elasticsearch failed to load elasticsearch nodes
  8. spark大数据快速分析第二章
  9. java Map的四种遍历方式
  10. poj 2186: Popular Cows(tarjan基础题)