51Testing软件测试论坛

标题: loadrunner编写C语言有关指针的问题 [打印本页]

作者: kevinlees    时间: 2017-11-3 18:24
标题: loadrunner编写C语言有关指针的问题
看到个例子麻烦解答下,有点看不懂了。先是 char *p=NULL,然后页面查找到了页面元素,并且统计了,然后就是把统计的数值赋值给p=lr_eval_string("{baidu_count}"),后续用*p作为变量去做做switch(*p);    疑惑的是*p 没有初始化的值,怎么会用到*p做变量呢?






Action()
{
        char *p=NULL;
        web_reg_find("Search=All",
                                 "SaveCount=baidu_count",
                                 "Text=head",
                                 LAST);
        web_url("www.baidu.cn",
                        "URL=http://www.baidu.cn/",
                        "Resource=0",
                        "RecContentType=text/html",
                        "Referer=",
                        "Snapshot=t1.inf",
                        "Mode=HTML",
                        LAST);
         p=lr_eval_string("{baidu_count}");
         switch (*p)
        {
         case '1':
                 lr_output_message("find 1");break;
         case '2':
                 lr_output_message("find 2");break;
         default:
                 lr_output_message("find another");

         }
        return 0;
}







欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2