int result;
char string1[] = "We can see the string:zee";
char string2[] = "We can see the string:zee";
lr_output_message("the string1 is %s.",string1);
lr_output_message("the string2 is %s.",string2);
result = strcmp(string1,string2);
if ( result == 0 )
{
lr_output_message("the result is 0.");
}
else
{
lr_output_message("the result is not 0.");
}
return 0;
}
运行结果:
Starting action vuser_init.
Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143]
Run-Time Settings file: "C:\Documents and Settings\Zee\Local Settings\Temp\noname26\\default.cfg" [MsgId: MMSG-27141]
vuser_init.c(7): the string1 is We can see the string:zee.
vuser_init.c(8): the string2 is We can see the string:zee.
vuser_init.c(13): the result is 0.
Ending action vuser_init.
Running Vuser...
[ 本帖最后由 Zee 于 2007-4-2 17:59 编辑 ]作者: QM 时间: 2007-4-2 18:06
厄。。。我已经拜读过版主的blog了。
版主大人,能够把这两句
char string1[] = "We can see the string:zee";
char string2[] = "We can see the string:zee";
替换成
lr_save_string( "We can see the string:zee","string1" );
lr_save_string( "We can see the string:zee","string2" );
比较一下么?我还是没太明白result = strcmp(string1,string2); 的语法。
我的string1和string2怎么会不等?
int result;
char string1;
char string2;
lr_save_string( "We can see the string:zee","string1" );
lr_save_string( "We can see the string:zee","string2" );
lr_output_message("the string1 is %s.",lr_eval_string("{string1}"));
lr_output_message("the string2 is %s.",lr_eval_string("{string2}"));
result = strcmp(lr_eval_string("{string1}"),lr_eval_string("{string1}"));
if ( result == 0 )
{
lr_output_message("the result is 0.");
}
else
{
lr_output_message("the result is not 0.");
}
return 0;
}
结果:
Starting action vuser_init.
Web Turbo Replay of LoadRunner 8.1.0 for WINXP; Web build 4788 [MsgId: MMSG-27143]
Run-Time Settings file: "C:\Documents and Settings\Zee\Local Settings\Temp\noname26\\default.cfg" [MsgId: MMSG-27141]
vuser_init.c(10): the string1 is We can see the string:zee.
vuser_init.c(11): the string2 is We can see the string:zee.
vuser_init.c(16): the result is 0.
Ending action vuser_init.
Running Vuser...作者: QM 时间: 2007-4-2 18:30
thanks a lot.作者: mfktafd 时间: 2007-4-3 10:01