原始代码:

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.comAction.c(19): tmp[1] = www.taobao.comAction.c(19): tmp[2] = www.csdn.comAction.c(19): tmp[3] = www.python.orgEnding action Action.Ending iteration 1.

loadrunner出现报错operands of = have illegal types `pointer to char' and `int'相关推荐

  1. python中json.loads报错: Expecting ‘,‘ delimiter: line 1 column 3545 (char 3544)

    在python中使用json.loads报错: Expecting ',' delimiter: line 1 column 3545 (char 3544) 原因: json字符串为: jsonSt ...

  2. [报错] TypeError: run() argument after * must be an iterable, not int

    [报错] TypeError: run() argument after * must be an iterable, not int 问题描述: 在多线程操作,调用threading.Thread ...

  3. leetcode报错:member access within null pointer of type struct ListNode

    leetcode报错:member access within null pointer of type 'struct ListNode'

  4. 解决json解析报错:Expecting value: line 1 column 1 (char 0)

    一般来说,出现这种Expecting value: line 1 column 1 (char 0)报错,一般原因都是返回的数据的格式不是json格式的. 今天在用flask写一个接口,测试接口的时候 ...

  5. jdk 1.8 java.policy,JDK1.8 导致系统报错:java.security.InvalidKeyException:illegal Key Size

    在使用JCE加密时,我们有时候会遇到这样的Exception: java.security.InvalidKeyException:illegal Key Size 要解决这个报错,首先,我们需要知道 ...

  6. flutter 报错java.net.URISyntaxException: Illegal character in opaque part at index 2

    记录flutter报错如下错误以及解决办法 FAILURE: Build failed with an exception. * What went wrong: Execution failed f ...

  7. 报错笔记:cannot convert parameter 1 from 'char [1024]' to 'unsigned char *'

    第一段:数组的类型是char,因此函数在引用const char 型的指针的时候,必须用char类型数组的首地址.如果是byte类型的指针的首地址,则会报cannot convert paramete ...

  8. SQL Server报错:Arithmetic overflow error converting expression to data type int.

    一.问题描述 sql server(sql dw)查询一张表数据个数,使用count报错 select count(*) from test.test_t; 然后报错: SQL 错误 [8115] [ ...

  9. leetcode报错:reference binding to misaligned address 0xbebebebebebec0ba for type ‘int‘, which requir 4

    leetcode,剑指offer 31题报错: Line 170: Char 16: runtime error: reference binding to misaligned address 0x ...

最新文章

  1. linux下发布的执行文件崩溃的问题定位 心得一则
  2. 1.13 南京站 | 2022 开年 Serverless 沉浸式技术实践营开始报名
  3. 东平县农民丰收节-农业大健康·万祥军:功能性谋定生态品牌
  4. 使用cordova进行App打包
  5. 安徽工程大学计算机控制,(完整版)安徽工程大学期末考试《计算机控制技术》范围总结2 .pdf...
  6. 用注水实验法验证勾股定理
  7. Rpc框架dubbo-client(v2.6.3) 源码阅读(二)
  8. CSS定义通用透明效果
  9. 并发-2-Thread和Runnable的API
  10. Two sum 二刷
  11. 线性同余法生成随机数Matlab_生成安全的随机数
  12. 优思学院|品质圈QCC是什么?如何有效实施?
  13. linux沙箱隔离_为容器提供更好的隔离:沙箱容器技术概览
  14. Java 将两个日期的时间段按照一定天数进行周期切割
  15. GoJS去除水印方法
  16. python自己的手稿四之互动沟通
  17. 字符编码和字符集基础知识
  18. 什么是BlockingQueue
  19. 单片机传输信息到服务器,单片机传数据到云服务器
  20. 微信服务器保留几年记录_微信聊天语音记录会在腾讯服务器保存多久?

热门文章

  1. 腾讯云“凶猛”,ToB、ToG都能打
  2. 浪漫的python代码_十行Python代码让你秒变撩妹达人,程序员浪漫起来就没有你们啥事了!...
  3. mybatisplus的CRUD基本使用心得--转载
  4. Xcode 配置python环境
  5. 张小娴经典语录- -
  6. 【Java内存溢出排查】gc监测以及内存突增问题排查
  7. 详解while((ch = getchar()) != EOF)
  8. php Wrapper LFI,利用PHP代码实现LFI2RCE
  9. nokia n9刷机
  10. C++的封装、继承、多态