原始代码:

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. centos系统下安装python3以及pip3

    首先查看一下系统当前的python版本 python -V 1.安装必要工具 yum-utils 它的功能是管理repository及扩展包的工具yum install yum-utils -y 2. ...

  2. python初级实战-----主机在线情况监控web

    背景 公司有600多台服务器,打算写一个小程序,能一眼看见哪些服务器不在线. 大体思路是: 1.把所有服务器ip存进数据库,ping命令判断服务器是否在线 2.更新数据库中ip的状态 3.简单的web ...

  3. k64 datasheet学习笔记31---External Bus Interface (FlexBus)

    1.前言 FlexBus多功能外部总线接口控制器是一个硬件模块: (1)通过并行总线提供存储器扩展或与外设连接: (2)如下的同步或异步的slave-only设备可以直连到FlexBus总线或者只需增 ...

  4. V4L2开发要点【转】

    转自:https://blog.csdn.net/mr_raptor/article/details/7441141 首先来看 Read/Write ,如果 VIDIOC_QUERYCAP 调用返回的 ...

  5. Git学习笔记02-创建版本库

    版本库就是一个目录,这个目录里面的所有文件都会被Git管理,每个文件的修改,删除都能追踪.以便在某个时刻追踪历史记录,或者还原 路径切换,查看文件命令和linux差不多,cd 文件路径  ls查看路径 ...

  6. C# 基础之const

    1.使用 const 关键字来声明某个常量字段或常量局部变量.常量字段和常量局部变量不是变量并且不能修改. 常量可以为数字.布尔值.字符串或 null 引用(Constants can be numb ...

  7. C# 操作文件类,文件夹存在判断,创建,文件内容读写。

    此篇文档是老早就放到草稿箱中了,断断续续编辑了几次.结合自己经常用到的对于文件的操作,结合msdn做此文. 1.File 类 --转自msdn 常用方法: 名称 说明 AppendAllLines(S ...

  8. 【转】JVM内存结构 VS Java内存模型 VS Java对象模型

    JVM内存结构 我们都知道,Java代码是要运行在虚拟机上的,而虚拟机在执行Java程序的过程中会把所管理的内存划分为若干个不同的数据区域,这些区域都有各自的用途. 其中有些区域随着虚拟机进程的启动而 ...

  9. ES--04

    第三十一讲! 分布式文档系统 写一致性原理以及相关参数 课程大纲 (1)consistency,one(primary shard),all(all shard),quorum(default) 我们 ...

  10. mina使用总结

    1.在会话中获得远程IP和端口 @Override public void messageReceived(IoSession session, Object message) throws Exce ...