以下脚本,定义两个一样的字符数组,对比后,打印出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. synchronize和lock的区别 & synchionzie与volatile的区别

    synchronized与Lock的区别 https://www.cnblogs.com/iyyy/p/7993788.html Lock和synchronized和volatile的区别和使用 ht ...

  2. vue 列表渲染 v-for

    1.数组列表       v-for 块中,我们拥有对父作用域属性的完全访问权限.v-for 还支持一个可选的第二个参数为当前项的索引 1.1 普通渲染       v-for="item ...

  3. 从零开始学MySQL(三)

    经过上两节的洗礼,我们能够连接上服务器,并成功地进入与mysql交互的会话中了.那么现在就可以发起SQL语句,让服务器来执行它了!这听起来很酷吧?接下来,我们开始学习MySQL的相关知识. 本文概览: ...

  4. iptables-save - 保存 IP Tables

    总览 SYNOPSIS iptables-save [-c] [-t table] 描述 DESCRIPTION iptables-save 用来将 IP Table 转储为可以简单解析的格式,输出到 ...

  5. Codeforces 979 字符串强制N变换最多出现字母 DFS子树 暴力01字典树

    A /* Huyyt */ #include <bits/stdc++.h> #define mem(a,b) memset(a,b,sizeof(a)) #define mkp(a,b) ...

  6. 2017 ICPC 南宁 L 带权最大递增子序列

    #include<cstdio> #include<iostream> #include<cstring> #include<cmath> #inclu ...

  7. Web Api 接口返回值不困惑:返回值类型详解

    前言:已经有一个月没写点什么了,感觉心里空落落的.今天再来篇干货,想要学习Webapi的园友们速速动起来,跟着博主一起来学习吧.之前分享过一篇 WebApi 接口参数:传参详解,这篇博文内容本身很基础 ...

  8. python paramiko模块:远程连接服务器

    1.  SFTP基于 用户名密码 登录服务器,实现上传下载: import paramiko transport = paramiko.Transport(()) # 生成trasport,配置主机名 ...

  9. mysql时间函数操作

    Mysql时间转换函数 https://blog.csdn.net/w_qqqqq/article/details/88863269 mysql时间日期函数 https://www.cnblogs.c ...

  10. java中list和map详解

    一.概叙 List , Set, Map都是接口,前两个继承至Collection接口,Map为独立接口, List下有ArrayList,Vector,LinkedList Set下有HashSet ...