LoadRunner中常用的C语言函数
2015-09-18 14:14
483 查看
函数名:strcat
功能:字符串拼接函数定义:char *strcat( char *to, const char *from);
char fullpath[1024], * filename = "logfile.txt"; strcpy(fullpath, "c:\\tmp"); strcat(fullpath, "\\"); strcat(fullpath, filename); lr_output_message ("Full path of file is %s", fullpath); Output: Action.c(9): Full path of file is c:\tmp\logfile.txt
函数名:strcmp
功能:两个字符串比较函数定义:int strcmp( constchar *string1, const char *string2);
int result; char tmp[20]; char string1[] = "The quick brown dog jumps over the lazy fox"; char string2[] = "The QUICK brown dog jumps over the lazy fox"; result = strcmp( string1, string2); // Case-sensitive comparison if(result > 0) strcpy(tmp, "greater than"); else if(result < 0) strcpy(tmp, "less than"); else strcpy(tmp, "equal to"); lr_output_message ("strcmp: String 1 is %s string 2", tmp); result = stricmp(string1, string2 ); // Case-insensitive comparison if( result > 0 ) strcpy( tmp, "greater than" ); else if( result < 0 ) strcpy( tmp, "less than" ); else strcpy( tmp, "equal to" ); lr_output_message( "stricmp: String 1 is %s string 2", tmp ); Output: Action.c(17): strcmp: String 1 is greater than string 2 Action.c(28): stricmp: String 1 is equal to string 2
返回值 | 描述 |
<0 | string1 小于string2 |
0 | string1 等于string2 |
>0 | string1 大于string2 |
函数名:strcpy
功能:将一个字符串复制到另一个字符串函数定义:char *strcpy( char *dest, const char *source);
char fullpath[1024], * filename = "logfile.txt"; strcpy(fullpath, "c:\\tmp"); lr_output_message ("fullpath after strcpy: %s", fullpath); strcat(fullpath, "\\"); strcat(fullpath, filename); lr_output_message ("Full path of file is %s", fullpath);} Output: Action.c(6): fullpath after strcpy: c:\tmp Action.c(10): Full path of file is c:\tmp\logfile.txt
函数名:strlen
功能:返回指定字符串的长度函数定义:size_t strlen( constchar *string
);
[align=left][/align]
int is_digit, i = 0; char * str = "1234567k89"; unsigned int len = strlen(str); do { if (i == len) { lr_output_message ("No letters found in string"); return -1; } is_digit = isdigit(str[i++]); } while (is_digit); lr_output_message ("The first letter appears in character %d of string", i);} Output: Action.c(18): The first letter appears in character 8 of string<strong> </strong>
相关文章推荐
- c语言中 ++i 和 i++ 问题!
- C++中string的用法 string字符串的使用方法
- C++多态
- c/c++ 实现split函数
- C#调用C++DLL的小总结5---和C++的DLL的联合调试
- 【C/C++学院】0813-C与CPP不同以及命名空间简介/函数重载与函数默认参数/泛型auto/Newdelete
- 用c语言的指针来对三个数进行排列
- C语言结构体大小计算
- C++类型转换
- 第3周项目2 建设“顺序表”算法库
- C++中两个头文件相互引用
- C++_wcout / C_wprintf (wcout输出中文)
- C++ typename 总结
- Item 30:理解inline函数的里里外外 Effective C++笔记
- 【C语言】关于宏定义中#和##符号的使用和宏定义展开问题
- C语言的几个常见冷知识
- 彻底搞定C语言指针(转)
- 学生信息管理系统(C语言版)
- C语言程序设计经典书籍
- c++ 代理类与句柄类实现思想