用strtok函数分割字符串

用strtok函数分割字符串

需要在loadrunner里面获得“15”(下面红色高亮的部分),并做成关联参数。

//Body response 内容: <BODY><; PRE>//OK[8,7,5,15,6,5,0,4,0,3,0,3,2,0,0,0,1

用web_reg_save_param取出“8,7,5,15,6,5,0,4,0,3,0,3,2,0,0,0,1”这一段,然后用strtok函数切割出一个个数字,第四个数字就是要找的值

例如:

extern char * strtok(char * string, const char * delimiters ); // Explicit declaration

char separators[] = ",";

char * token;

lr_save_string("1,2,3,4,5,6","str");

token = (char *)strtok(lr_eval_string("{str}"), separators); // Get the first token

if (!token) {

lr_output_message ("No tokens found in string!");

return( -1 );

}

while (token != NULL ) { // While valid tokens are returned

lr_output_message ("%s", token );

token = (char *)strtok(NULL, separators); // Get the next token

}

用strtok函数分割字符串

需要在loadrunner里面获得“15”(下面红色高亮的部分),并做成关联参数。

//Body response 内容: <BODY><; PRE>//OK[8,7,5,15,6,5,0,4,0,3,0,3,2,0,0,0,1

用web_reg_save_param取出“8,7,5,15,6,5,0,4,0,3,0,3,2,0,0,0,1”这一段,然后用strtok函数切割出一个个数字,第四个数字就是要找的值

例如:

extern char * strtok(char * string, const char * delimiters ); // Explicit declaration 

char separators[] = ",";

char * token; 

lr_save_string("1,2,3,4,5,6","str");

token = (char *)strtok(lr_eval_string("{str}"), separators); // Get the first token 

if (!token) { 

        lr_output_message ("No tokens found in string!"); 

        return( -1 ); 

    } 

while (token != NULL ) { // While valid tokens are returned 

        lr_output_message ("%s", token ); 

        token = (char *)strtok(NULL, separators); // Get the next token 

    }
上一篇:cloudstack agent host Alert 告警处理


下一篇:RGB格式图像转化为HSV格式