LR中用C语言比较两个字符串变量

一:
以下脚本,定义两个一样的字符数组,对比后,打印出result的值:

1.  vuser_init()

2.  {

3.  int result;

4.       char string1[] = "We can see the string:nancy";

5.       char string2[] = "We can see the string:nancy";

6.  lr_output_message("the string1 is %s.",string1);

7.  lr_output_message("the string2 is %s.",string2);

8.  result = strcmp(string1,string2);  

9.     if ( result == 0 )

10.           {

11.        lr_output_message("the result is 0.");

12.        }

13.   else

14.   {

15.     lr_output_message("the result is not 0.");

16.   }

17.        return 0;

18.}

复制代码

运行结果:

1.  Starting action vuser_init.

2.  Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788          [MsgId: MMSG-27143]

3.  Run-Time Settings file: "C:\Documents and Settings\Zee\Local Settings\Temp\noname26\\default.cfg"          [MsgId: MMSG-27141]

4.  vuser_init.c(7): the string1 is We can see the string:nancy.

5.  vuser_init.c(8): the string2 is We can see the string:nancy.

6.  vuser_init.c(13): the result is 0.

7.  Ending action vuser_init.

8.  Running Vuser...

复制代码

二:
脚本:

1.  vuser_init()

2.  {

3.  int result;

4.  char string1;

5.  char string2;

6.       lr_save_string( "We can see the string:nancy","string1" );

7.       lr_save_string( "We can see the string:nancy","string2" );

8.  lr_output_message("the string1 is %s.",lr_eval_string("{string1}"));

9.  lr_output_message("the string2 is %s.",lr_eval_string("{string2}"));

10.result = strcmp(lr_eval_string("{string1}"),lr_eval_string("{string2}"));  

11.   if ( result == 0 )

12.           {

13.        lr_output_message("the result is 0.");

14.        }

15.   else

16.   {

17.     lr_output_message("the result is not 0.");

18.   }

19.        return 0;

20.}

复制代码

结果:

1.  Starting action vuser_init.

2.  Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788          [MsgId: MMSG-27143]

3.  Run-Time Settings file: "C:\Documents and Settings\Zee\Local Settings\Temp\noname26\\default.cfg"          [MsgId: MMSG-27141]

4.  vuser_init.c(10): the string1 is We can see the string:nancy.

5.  vuser_init.c(11): the string2 is We can see the string:nancy.

6.  vuser_init.c(16): the result is 0.

7.  Ending action vuser_init.

8.  Running Vuser...

复制代码

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值