原始代码:

  1. void split(char * p,char * str){
  2. /*
  3. 传入一个数组进行p和一个以什么进行分割的str,返回切片后的值
  4. */
  5. int i = 0, j = 0;
  6. char tmp[32][32] = {0};
  7. char *p1 = (char *)malloc(1024);
  8. while((p1 = strchr(p, *str)) != NULL) //10行
  9. {
  10. strncpy(tmp[i], p, strlen(p) - strlen(p1));
  11. p = p1 + 1;
  12. i ++;
  13. }
  14. strncpy(tmp[i], p, strlen(p));
  15. for(j = 0; j <= i; j++){
  16. lr_output_message("tmp[%d] = %s\n", j, tmp[j]);
  17. }
  18. }
  19. Action (){
  20. char p[] = "www.baidu.com,www.taobao.com,www.csdn.com,www.python.org";
  21. char str[] = ","; //分割的字符串
  22. split(p,str);
  23. return 0;
  24. }

运行后第10行出现指针报错:operands of = have illegal types `pointer to char’ and `int’ ,百思不得其解,dev-C++中运行一切正常,各种排查后发现传参确实符合要求,但第10行给指针变量赋值时未对strchr返回的值进行强制类型转换(等于直接给指针变量赋值(太粗心了-_-!!))

修改后脚本:

  1. void split(char * p,char * str){
  2. /*
  3. 传入一个数组进行p和一个以什么进行分割的str,返回切片后的值
  4. */
  5. int i = 0, j = 0;
  6. char tmp[32][32] = {0};
  7. char *p1 = (char *)malloc(1024);
  8. while((p1 = (char *)strchr(p, *str)) != NULL) //必须使用(char *)进行强制类型转换
  9. {
  10. strncpy(tmp[i], p, strlen(p) - strlen(p1));
  11. p = p1 + 1;
  12. i ++;
  13. }
  14. strncpy(tmp[i], p, strlen(p));
  15. for(j = 0; j <= i; j++){
  16. lr_output_message("tmp[%d] = %s\n", j, tmp[j]);
  17. }
  18. }
  19. Action (){
  20. char p[] = "www.baidu.com,www.taobao.com,www.csdn.com,www.python.org";
  21. char str[] = ","; //分割的字符串
  22. split(p,str);
  23. return 0;
  24. }
  25. loadrunner中执行结果:
  26. Starting iteration 1.
  27. Starting action Action.
  28. Action.c(19): tmp[0] = www.baidu.com
  29. Action.c(19): tmp[1] = www.taobao.com
  30. Action.c(19): tmp[2] = www.csdn.com
  31. Action.c(19): tmp[3] = www.python.org
  32. Ending action Action.
  33. 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. whatis命令,一个非常有用的命令

    比如我不知道yum的配置文件yum.conf怎么用,就可以whatis yum.conf,

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

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

  3. yum upgrade卡在 清理initial-setup-0.3.9.30-1.el7.centos.x86_64

    我安装CENTOS7.2,用yum -y update进行更新 卡在这里了 清理 : initial-setup-0.3.9.30-1.el7.cent 目测是一个系统bug,执行关闭命令解决: sy ...

  4. 【转】Python之mmap内存映射模块(大文本处理)说明

    [转]Python之mmap内存映射模块(大文本处理)说明 背景: 通常在UNIX下面处理文本文件的方法是sed.awk等shell命令,对于处理大文件受CPU,IO等因素影响,对服务器也有一定的压力 ...

  5. GeoDesc: Learning Local Descriptors by Integrating Geometry Constraints

    这篇论文提出了一种新的局部描述子学习方法,有一些点值得学习,记录下来以供参考.文章中涉及了一些3D reconstruction.structure from 的知识,不是很了解,所以理解可能有偏颇. ...

  6. R-FCN论文讲解(转载链接)

    总结一下一下R-FCN的思想:由于分类网络具有位置的“不敏感性”和检测网络具有“位置的敏感性”这两者之间的矛盾, 而ResNet论文中为了解决这个问题,做出了一点让步,即将RoI Pooling层不再 ...

  7. Nginx range filter模块数字错误漏洞修复 (Nginx平滑升级) 【转】

    对线上生产环境服务器进行漏洞扫描, 发现有两台前置机器存在Nginx range filter模块数字错误漏洞, 当使用nginx标准模块时,攻击者可以通过发送包含恶意构造range域的header ...

  8. 通过全备+relaylog同步恢复被drop的库或表【转】

    MySQL 中drop 等高危误操作后恢复方法 实验目的: 本次实验以恢复drop操作为例,使用不同方法进行误操作的数据恢复. 方法: 利用master同步 伪master+Binlog+同步 利用b ...

  9. arx对正在操作的文件进行保存

    //对正在操作的文件进行保存 STDMETHODIMP CTHDatabase::Save(void) { // TODO: 在此添加实现代码 Acad::ErrorStatus es ; try{ ...

  10. 蓝皮书:异象石 【dfs序+lca】

    题目详见蓝皮书[算法竞赛:进阶指南]. 题目大意: 就是给你一颗树,然后我们要在上面进行三种操作:  1.标记某个点  或者  2.撤销某个点的标记  以及   3.询问标记点在树上连通所需的最短总边 ...