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

Action()
{ int result;
char string1[] = "We can see the string:nancy";
char string2[] = "We can see the string:nancy";
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;
}

  

  

运行结果:

Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(7): the string1 is We can see the string:nancy.
Action.c(8): the string2 is We can see the string:nancy.
Action.c(12): the result is 0.
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

代码2:

Action()
{ int result;
char string1;
char string2;
lr_save_string( "We can see the string:nancy","string1" );
lr_save_string( "We can see the string:nancy","string2" );
lr_output_message("the string1 is %s.",lr_eval_string("{string1}"));
lr_output_message("the string1 is %s.",lr_eval_string("{string2}"));
result = strcmp(lr_eval_string("{string1}"),lr_eval_string("{string2}"));
if ( result == 0 )
{
lr_output_message("the result is 0.");
}
else
{
lr_output_message("the result is not 0.");
} return 0;
}

  

运行结果:

Ending action vuser_init.
Running Vuser...
Starting iteration 1.
Starting action Action.
Action.c(9): the string1 is We can see the string:nancy.
Action.c(10): the string1 is We can see the string:nancy.
Action.c(14): the result is 0.
Ending action Action.
Ending iteration 1.
Ending Vuser...
Starting action vuser_end.
Ending action vuser_end.
Vuser Terminated.

lr中用C语言比较两个字符串变量的更多相关文章

  1. C语言 ,两个字符串参数,判断是否包含另一个字符串,返回所在位置

    char * cyp(char *s1,char *s2) { char *p = NULL; char *q = NULL; char *q1 = NULL; while(*s1!='\0') { ...

  2. C语言: 两个int变量相除,结果保留两位小数

    #include<stdio.h> void main() { ,j=; float h; h=(*/)/; printf("%.2f",h); } 注:%f:不指定宽 ...

  3. jsp用equals判断两个字符串变量是否相等

    使用即可: s1.equals(s2) 如果使用场景: if(s1==s2){} 这样使用可能会出现判断无效的情况. 使用if(s1.equals(s2)){}就可以了.

  4. c语言中的利用函数实现交换两个字符,交换两个字符串

    c语言交换两个字符: 方法一:利用指针传址,效率比较高 void swap(int *a,int *b) { int temp; temp = *a; *a = *b; *b = temp } 方法二 ...

  5. PHP 字符串变量

    PHP 字符串变量 字符串变量用于存储并处理文本. PHP 中的字符串变量 字符串变量用于包含有字符的值. 在创建字符串之后,我们就可以对它进行操作了.您可以直接在函数中使用字符串,或者把它存储在变量 ...

  6. php之快速入门学习-6(字符串变量)

    PHP 字符串变量 字符串变量用于存储并处理文本. PHP 中的字符串变量 字符串变量用于包含有字符的值. 在创建字符串之后,我们就可以对它进行操作了.您可以直接在函数中使用字符串,或者把它存储在变量 ...

  7. PHP 中的字符串变量

    PHP 字符串变量 字符串变量用于存储并处理文本. PHP 中的字符串变量 字符串变量用于包含有字符的值. 在创建字符串之后,我们就可以对它进行操作了.您可以直接在函数中使用字符串,或者把它存储在变量 ...

  8. C语言strcmp()函数:比较两个字符串

    strcmp() 函数用于对两个字符串进行比较(区分大小写). 头文件:string.h 语法/原型: int strcmp(const char* stri1,const char* str2); ...

  9. C语言:写一函数,将两个字符串中的元音字母复制到另一个字符串,然后输出

    题目描述 写一函数,将两个字符串中的元音字母复制到另一个字符串,然后输出. 输入 一行字符串 输出 顺序输出其中的元音字母(aeiuo) 样例输入 abcde 样例输出 ae 编码: #include ...

随机推荐

  1. 将ShellCode注入进程内存

    内存注入ShellCode的优势就在于被发现的概率极低,甚至可以被忽略,这是因为ShellCode被注入到进程内存中时,其并没有与之对应的硬盘文件,从而难以在磁盘中取证,但也存在一个弊端由于内存是易失 ...

  2. Go基础学习

    Go基础学习 go的基础语法 fmt.Println("hello world!") //go采用行分隔符 关键字 下面列举了 Go 代码中会使用到的 25 个关键字或保留字: b ...

  3. decode与case when 函数

    百度百科: DECODE函数,是ORACLE公司的SQL软件ORACLE PL/SQL所提供的特有函数计算方式,以其简洁的运算方式,可控的数据模型和灵活的格式转换而闻名. DECODE 中的if-th ...

  4. vue-awesome-swiper轮播插件

    1. github上搜索vue-awesome-swiper 2. readme中有安装方法,建议在插件名后@版本号,使用稳定的老版本 npm install vue-awesome-swiper@x ...

  5. 关于android studio从2.3升级到3.0以上可能会遇到的问题

    请参考链接: http://blog.csdn.net/hylczp/article/details/60137958 gradle-3.3-all网盘下载地址: 链接:http://pan.baid ...

  6. C/C++ 零碎知识点

    传递参数的一般指导原则: 对于使用传递的值而不做修改的函数: 如果数据对象很小,比如内置类型或者小型结构,按值传递. 如果数据对象是数组,只能使用指针,并将指针生命为指向const的指针. 如果数据对 ...

  7. 电脑系统win7和samba服务器连接不上解决办法

    1.修改本地安全策略运行secpol.msc打开“本地安全策略”窗体,依次点开“本地策略”->“安全选项”,修改“网络安全: LAN 管理器身份验证级别”的值为“发送 LM 和 NTLM – 如 ...

  8. 绕过CDN找到真实IP

    现在很多大型企业都会使用CDN内容分发网络,因为CDN存在多个缓存服务点,而且会根据用户IP地址,将用户请求导向到最近的服务点上进行相应,所以得不到主服务站点的ip地址,总结学习一下绕过CDN找到真实 ...

  9. 清楚webView的缓存

    +(void)clearCache{    NSHTTPCookie *cookie;    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage s ...

  10. web性能优化--服务器端(二)

    静态资源用CDN部署 添加Expires或者cache-control报文头 Gzip压缩传输文件 配置Etags 使用Get ajax请求 避免空图片src 尽早flush response 减少c ...