脚本如下:
Starting action Action. [MsgId: MMSG-15919]
Action.c(11): groupname=CHANGE [MsgId: MMSG-17999]
Action.c(16): lower case groupname=change [MsgId: MMSG-17999]
运行后在log中看到如下语句:
Action.c(13): The sentence has 18 letters
char *strncat ( char *to_string, const char *from_string, size_t n );
功能:把一个字符串连接到另一个字符串后面。
例子:
在这里,我随便写了两个字符串,用此函数把他们连接起来,并打印出来。
脚本如下:
char str1[]="Cheers is ";
char str2[]="a tester.";
lr_output_message("What can we see?");
lr_output_message("The str1 is %s.",str1);
strncat(str1,str2,20);
lr_output_message("The str1 is %s.",str1);
运行后在log中看到如下语句:
Action.c(9): What can we see?
Action.c(10): The str1 is Cheers is .
Action.c(13): The str1 is Cheers is a tester..
注:我们可以看到,没有连接前的str1是:Cheers is,连接后的字符串是:Zee is a tester。也可以看看strcat函数。
int strncmp ( const char *string1, const char *string2, size_t n );
功能:对比两个字符串的前n位。
例子:
对比两个字符串,并把对比结果打印出来。这里我和上面的strcmp一起写。
脚本如下:
char result;
char str1[]="Cheers is a tester.";
char str2[]="Cheers is a tester.";
char str3[]="Cheers is a tester?";
result = strcmp(str1,str2);
if(result > 0)
lr_output_message("str1 is greater than str2.");
else if(result < 0)
lr_output_message("str1 is less than str2.");
else
lr_output_message("str1 is equal to str2.");
result = strncmp( str1, str3 , 30);
if(result > 0)
lr_output_message("str1 is greater than str3.");
else if(result < 0)
lr_output_message("str1 is less than str3.");
else
lr_output_message("str1 is equal to str3.");
运行后在log中看到如下语句:
Starting iteration 1.
Starting action Action.
Action.c(18): str1 is equal to str2.
Action.c(28): str1 is less than str3.
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-38054-3.html
而这样的新闻炒作真的是恶心
挺好
可以射击并击沉
美国佬在叙利亚被普京把了脸跑到南海来撒野