loadrunner出现报错operands of = have illegal types `pointer to char' and `int'
原始代码:
void split(char * p,char * str){
/*
传入一个数组进行p和一个以什么进行分割的str,返回切片后的值
*/
int i = 0, j = 0;
char tmp[32][32] = {0};
char *p1 = (char *)malloc(1024);
while((p1 = strchr(p, *str)) != NULL) //10行
{
strncpy(tmp[i], p, strlen(p) - strlen(p1));
p = p1 + 1;
i ++;
}
strncpy(tmp[i], p, strlen(p));
for(j = 0; j <= i; j++){
lr_output_message("tmp[%d] = %s\n", j, tmp[j]);
}
}
Action (){
char p[] = "www.baidu.com,www.taobao.com,www.csdn.com,www.python.org";
char str[] = ","; //分割的字符串
split(p,str);
return 0;
}
运行后第10行出现指针报错:operands of = have illegal types `pointer to char’ and `int’ ,百思不得其解,dev-C++中运行一切正常,各种排查后发现传参确实符合要求,但第10行给指针变量赋值时未对strchr返回的值进行强制类型转换(等于直接给指针变量赋值(太粗心了-_-!!))
修改后脚本:
void split(char * p,char * str){
/*
传入一个数组进行p和一个以什么进行分割的str,返回切片后的值
*/
int i = 0, j = 0;
char tmp[32][32] = {0};
char *p1 = (char *)malloc(1024);
while((p1 = (char *)strchr(p, *str)) != NULL) //必须使用(char *)进行强制类型转换
{
strncpy(tmp[i], p, strlen(p) - strlen(p1));
p = p1 + 1;
i ++;
}
strncpy(tmp[i], p, strlen(p));
for(j = 0; j <= i; j++){
lr_output_message("tmp[%d] = %s\n", j, tmp[j]);
}
}
Action (){
char p[] = "www.baidu.com,www.taobao.com,www.csdn.com,www.python.org";
char str[] = ","; //分割的字符串
split(p,str);
return 0;
}
loadrunner中执行结果:
Starting iteration 1.
Starting action Action.
Action.c(19): tmp[0] = www.baidu.com
Action.c(19): tmp[1] = www.taobao.com
Action.c(19): tmp[2] = www.csdn.com
Action.c(19): tmp[3] = www.python.org
Ending action Action.
Ending iteration 1.
loadrunner出现报错operands of = have illegal types `pointer to char' and `int'的更多相关文章
- 力扣 报错 runtime error: load of null pointer of type 'const int'
runtime error: load of null pointer of type 'const int' 要求返回的是int* 解决方案 1.指针使用malloc分配空间 用 int * p = ...
- input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'
今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...
- AOP拦截日志报错llegalStateException: It is illegal to call this method if the current request is not in asynchronous mode
原文链接:https://my.oschina.net/mengzhang6/blog/2395893 关于一次AOP拦截入参记录日志报错的梳理总结 将服务发布到tomcat中后,观察服务的运行状态以 ...
- JQ报错:Uncaught SyntaxError: Illegal continue statement: no surrounding iteration statement报错
今天在写轮播图中,在停止定时器之后想要重新开启定时器,但是不知道为什么脑子抽了竟然想通过continue跳出定时器的本次运行继续下一次运行(当然是不可取的,但是还是试了试2333),然后就报错了.Un ...
- loadrunner场景报错:Error: CCI compilation error -/tmp/brr_5d65oV/netdir/E/\320\324/Action.c (318): undeclared identifier `LAST'解决思路
在windows下写的脚本编译通过 但是拿到linux agent场景执行中就会提示如下,同样的脚本在windows agent下没有任何问题 agent连的是linux负载机 通过脚本一行一行排查, ...
- air报错 Error: Error #3000: Illegal path name
配置增加: <supportedProfiles>extendedDesktop desktop</supportedProfiles> fb: flash:
- PHP7.1 报错 Warning Illegal string offset
报错如下: Warning: Illegal string offset '阿根廷' in F:\wnmp\www\test.php on line 24 Warning: Illegal strin ...
- jQuery跳出each循环:JS报错:illegal break statement
今天在JS中运用jquery中each写一个简单的循环语句时,在执行跳出循环操作时,遇到JS报错:Uncaught SyntaxError: illegal break statement 非法的br ...
- 创建spring boot项目启动报错遇到的问题
1.Spring boot,Mybatis 启动报错 Failed to auto-configure a DataSource *************************** APPLICA ...
随机推荐
- Challenge Create a Launch Pad
在头文件中定义网格体组件和重叠组件 UPROPERTY(VisibleAnywhere,Category="Components") UStaticMeshComponent* M ...
- python - 编程规范问题
软件目录结构规范alex_老男孩:为什么要设计好目录结构?“设计项目目录结构”,就和“胆码编码风格”一样,属于个人风格问题.对于这种风格上的规范,一直都存在两种态度: 1.一类同学认为,这种个人 ...
- MySql cmd下的学习笔记 —— 有关select的操作(max, min等常见函数)
先把之前建的goods表找到 找到最贵的本店价(max) 找到最便宜的本店价(min) 查出一共还有多少商品(count) 查看商品价的平均价(avg) 查看本店有多少种商品 当count(*)时 输 ...
- Aizu 2170 Marked Ancestor
题意:出一颗树,有两种操作:1. mark u 标记结点u2.query u 询问离u最近的且被标记的祖先结点是哪个让你输出所有询问的和. 思路:数据量太小,直接暴力dfs就可以了 #incl ...
- 6034 Balala Power! (17多校)
题目大意:给出的字符串,每个字符建立一种与0-25的对应关系.然后每个字符串看成是一个26进制的数.问能获得的数的总和的最大值.(最后对1e9+7取模). 题目思考:把每个字符的贡献值看做一个26进制 ...
- 虚拟机克隆后无法上网的解决(Centos7为例)
说明:我的虚拟机之前配置的为静态ip 解决步骤: (1)更换mac地址 (2)删除 etc/udev/rules.d/70-persistent-net.rules 删除后重启机器,系统会自动生成一个 ...
- 不指定虚拟路径的前提下通过http访问pdf、图片等文件
通常我们通过http访问图片或者pdf的时候都是将文件上传到指定文件夹下面,然后通过配置虚拟路径来访问指定的资源. 在不配置虚拟路径的情况下,我们通过获取到response的outpurstream, ...
- 【转】PyQt5开发环境配置并使用
[转]PyQt5开发环境配置并使用 https://blog.csdn.net/HuangZhang_123/article/details/78046706 本人新书<玩转Python网络爬虫 ...
- Linux运行时I/O设备的电源管理框架【转】
转自:https://www.cnblogs.com/coryxie/archive/2013/03/01/2951243.html 本文介绍Linux运行时I/O设备的电源管理框架.属于Linux内 ...
- css3实现不同进度条
进度条类型1(渐变进度条) 效果1:图片实现进度条 思路,进度条是一张图片,用定位来控制不同时间图片相对进度条box的left值来控制位置,用animate实现动画效果 html <div cl ...