Code 1:
#include "web_api.h"51Testing软件测试网|UPs-xt,i.U4F)C
Action()51Testing软件测试网 `2b+VY#D]
oC
{51Testing软件测试网'KShQ^.qZgLQ
char string[1024] ;
i]'PUL5L6yhE&yqm0char num[1024];
Z To a?"[]r*z0int s; //定义变量S,目的是接收新生成的随机数
*dY%^!HYx"Y @;E0 int i;//循环变量51Testing软件测试网`*F)h"\9`P z u!A
char str[10];//定义数组接受整型变量转化为字符串的赋值
SJo!m!cQn8K8W0 for(i=0;i<=9;i++)//循环生成10个随机数
HOs3wHVWHn0 {51Testing软件测试网!O3GE l;bEP!D Y
s=rand();//调用库函数,生成随机数
//s=rand()%200; //限制随机数的范围最大为200.
//s=rand()%100+200; //限制随机数的范围为200---300.
// lr_output_message("s=%d",s);
7]W+mgH-e
iH@0}0 if (!itoa(s, str, 10))//将int型转为字符串
b|+ry5X"c(gG0 {51Testing软件测试网8m:RVi|s{
lr_output_message("Cannot convert i to char");
X)L[y ?D;v6X/hE}0 //lr_output_message("str=%s",str);
rpciUJB)W'B6o0 }51Testing软件测试网6LJT }+kk}8Kk
//sprintf (str, "log_%s.txt", str);
p+g~.F;P3Z0 lr_save_string(str,"num");//建立参数num接受转换过后的值
// lr_output_message("num : %s", lr_eval_string("The row count is: {num}"));
_XON~"F0 strcpy(string, "XXXX!!!");51Testing软件测试网2U:yc8RS2wL!oS.{
strcat(string,lr_eval_string("{num}"));51Testing软件测试网{
u"M@_RLqW:E
lr_output_message("New String is :: %s",string);
e8mv9vd*q:I,A0 //获取参数值,并循环输出该参数的值51Testing软件测试网6De1Z%TB RcA#s
}51Testing软件测试网:A Mu+g%Vr
//lr_output_message("New file name %s", str);51Testing软件测试网
}4A"Q`[/Y~^
}
Code 2:
#include "web_api.h"51Testing软件测试网a4jJ(sPKhS
Action()
3z@XEE3R8{C"{0{
ezQP,[|!j,o(i0char string[1024] ;51Testing软件测试网U#u?v5VB\
char num[1024];
|-Am AmCWq8S/^
q3V0int s; //定义变量S,目的是接收新生成的随机数
pl?tb@0 int i;//循环变量51Testing软件测试网j$K@6[2t(xQ
char str[10];//定义数组接受整型变量转化为字符串的赋值51Testing软件测试网+S'hZ2?\%ud
for(i=0;i<=9;i++)//循环生成10个随机数
`k'O]]j*P Ykz0 {
M/L
[0xX)T,Lq2F0 s=rand();//调用库函数,生成随机数
//s=rand()%200; //限制随机数的范围最大为200.
//s=rand()%100+200; //限制随机数的范围为200---300.
// lr_output_message("s=%d",s);
9l6}Awc4m0 if (!itoa(s, str, 10))//将int型转为字符串
\/c0mh;X&i%k0q/w_x i0 {
j f*]4S1u`0cq0 lr_output_message("Cannot convert i to char"); 51Testing软件测试网.PBx,Y'Wc
//lr_output_message("str=%s",str);
4t!n4ll4EdV0 }
q+\c`y I0//sprintf (str, "log_%s.txt", str);51Testing软件测试网qm.XsQo?1B$N8|
lr_save_string(str,"num");//建立参数num接受转换过后的值
// lr_output_message("num : %s", lr_eval_string("The row count is: {num}")); 51Testing软件测试网x}-Cl7o&OV
strcpy(string, "我是中国人!!!"); //copy后面的值给前面的字符串
/lz)nV
?P.B%rx0 strcat(string,lr_eval_string("{num}"));//连接两字符串51Testing软件测试网 K"si4m)C$I]
lr_output_message("New String is :: %s",string);51Testing软件测试网v5Fb&s z,bD,|K5Vp
//获取参数值,并循环输出该参数的值
lr_save_datetime("%H:%M:%S", DATE_NOW + ONE_DAY, "next");
](udE!z@fx9V0 lr_output_message(lr_eval_string("{next}")); 51Testing软件测试网~:sdr2Z k
}
r
@LuX Pc3t1f
v0//lr_output_message("New file name %s", str);
!W#G!riu;x@2|0}
Code3 :srand 函数
#include "web_api.h"51Testing软件测试网?f7H.PI?
Action()
8ucy\1VV"Rnw{ t0{51Testing软件测试网N+J;\
t9d)iM/C
//srand is called before rand
srand(time(NULL));
/* Generate some random numbers */
lr_output_message("A number between 0 and 100: %d\n", rand() % 100);
lr_output_message ("A number between 20 and 30: %d\n", rand() % 10+20);
!r3_8spAj5d2c0return 0;51Testing软件测试网mkT6l/QXS
B8O
}
Code 4 : rand取系统时间连接
#include "web_api.h"
Action()51Testing软件测试网s
f[$My"A
b
{ char next[1024];
char string[1024] ;51Testing软件测试网G/h4r[`
char num[1024];
aH2?7b2`kFq1a'n0int s; //定义变量S,目的是接收新生成的随机数51Testing软件测试网/T/@5IK1i"faC
int i;//循环变量
UC a2G'D
D9t0 char str[10];//定义数组接受整型变量转化为字符串的赋值51Testing软件测试网_d XGcpv'K7I
for(i=0;i<=9;i++)//循环生成10个随机数51Testing软件测试网2pj1K%a;v5gON
{51Testing软件测试网'_9Bm
owb SsAc
s=rand();//调用库函数,生成随机数
//s=rand()%200; //限制随机数的范围最大为200.
//s=rand()%100+200; //限制随机数的范围为200---300.
// lr_output_message("s=%d",s);
4E0B3o)M4Q$R:U0 if (!itoa(s, str, 10))//将int型转为字符串51Testing软件测试网B[ac-Ljl7^9u8X
{
UJ.}wv6E^D;[v0 lr_output_message("Cannot convert i to char");
7IW bL7i2d#p7F'd0 //lr_output_message("str=%s",str);
"vC;?2W8HR_0s[V:\0 }51Testing软件测试网7aR4h5`W {
//sprintf (str, "log_%s.txt", str);51Testing软件测试网
EE7Q8F%ur2Tsx
lr_save_string(str,"num");//建立参数num接受转换过后的值51Testing软件测试网#v fz9z ey9e
lr_save_datetime("%H%M%S", DATE_NOW + ONE_DAY, "next");
r@3Q `ysC:N6K@G0 lr_output_message("num : %s", lr_eval_string("The row count is: {num}"));
:@E6I$JQ^0 strcpy(string, lr_eval_string("{next}"));
K:n"W,UO1Uk0 strcat(string,lr_eval_string("{num}"));51Testing软件测试网(x"k1gfFxJ
lr_output_message("New String is :: %s", string);51Testing软件测试网FA x5|+v;M
//获取参数值,并循环输出该参数的值51Testing软件测试网(`$}&V6s(?
}
Ya \bx6YI0 return 0;51Testing软件测试网UjoG5[8G9P@
}