原始代码:

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'的更多相关文章

  1. 力扣 报错 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 = ...

  2. input()报错:TypeError: '>=' not supported between instances of 'str' and 'int'

    今天学习python基础—分支与循环,接触到了if.在练习一个if语句的时候,出现了错误. 题目是: 根据分数划分成四个级别:优秀.良好.及格.不及格,分数是72: grade = 72if grad ...

  3. 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中后,观察服务的运行状态以 ...

  4. JQ报错:Uncaught SyntaxError: Illegal continue statement: no surrounding iteration statement报错

    今天在写轮播图中,在停止定时器之后想要重新开启定时器,但是不知道为什么脑子抽了竟然想通过continue跳出定时器的本次运行继续下一次运行(当然是不可取的,但是还是试了试2333),然后就报错了.Un ...

  5. 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负载机 通过脚本一行一行排查, ...

  6. air报错 Error: Error #3000: Illegal path name

    配置增加: <supportedProfiles>extendedDesktop desktop</supportedProfiles> fb: flash:

  7. PHP7.1 报错 Warning Illegal string offset

    报错如下: Warning: Illegal string offset '阿根廷' in F:\wnmp\www\test.php on line 24 Warning: Illegal strin ...

  8. jQuery跳出each循环:JS报错:illegal break statement

    今天在JS中运用jquery中each写一个简单的循环语句时,在执行跳出循环操作时,遇到JS报错:Uncaught SyntaxError: illegal break statement 非法的br ...

  9. 创建spring boot项目启动报错遇到的问题

    1.Spring boot,Mybatis 启动报错 Failed to auto-configure a DataSource *************************** APPLICA ...

随机推荐

  1. 黑客游戏_www.fbisb.com 通关过程

    黑客游戏_www.fbisb.com 首先这个游戏是非常非常基础的. 输入网址 http://www.fbisb.com/youxi/ 来到第一关 ctrl+u查看源码,注意右键不行,因为这段js代码 ...

  2. Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields(翻译)

    0 - Abstract 我们提出了一种方法去在一张图片中有效地识别多个人体的2D姿势.这个方法使用了一个无参数表示法,我们将其叫为Part Affinity Fields(PAFs),其是去在图片中 ...

  3. Django学习手册 - 连接mysql数据库

    版本问题: 首先确认django.msql.python版本是统一支持 当前所用的版本信息: Django setting.py 配置 替换之前的DATABASES 配置: DATABASES = { ...

  4. cxf动态调用外部web service 报告异常java.lang.NoSuchFieldError: QUALIFIED

    原因:cxf 依赖的xmlschema-core 与xfire-all依赖的xmlschema冲突.(百度搜索亦得知:cxf 依赖的xmlschema-core 与axis2-kernel依赖的xml ...

  5. IndexedDB API

    参考链接:https://wangdoc.com/javascript/bom/indexeddb.html

  6. 20165237 2017-2018-2 《Java程序设计》第2周学习总结

    20165237 2017-2018-2 <Java程序设计>第2周学习总结 教材学习内容总结 1.标识符第一个字符不能是数字. 2.标识符不能是关键字,也不能是true.false和nu ...

  7. python第六天函数,定义、调用、不带参函数、带参函数等

    在python定义函数需要用到的关键字是 def  xxxx():,这个关键字就是 defined 的缩写.具体看实例: >>> def hello(): print("你 ...

  8. [转] 深入理解Batch Normalization批标准化

    转自:https://www.cnblogs.com/guoyaohua/p/8724433.html 郭耀华's Blog 欲穷千里目,更上一层楼项目主页:https://github.com/gu ...

  9. 普通函数跟箭头函数中this的指向问题

    箭头函数和普通函数的区别如下. 普通函数:根据调用我的人(谁调用我,我的this就指向谁) 箭头函数:根据所在的环境(我再哪个环境中,this就指向谁) 一针见血式总结: 普通函数中的this: 1. ...

  10. 【51nod1847】 奇怪的数学题

    就当我是 A 了此题吧... 首先预备知识有点多(因为题目要处理的东西都挺毒瘤): 杜教筛运用(当然你可以用其他筛?) 第二类斯特林数相关定理 下降阶乘幂相关定理 min25 筛运用 好了可以关掉本题 ...