Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1019840
  • 博文数量: 157
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1388
  • 用 户 组: 普通用户
  • 注册时间: 2015-04-09 15:37
文章分类

全部博文(157)

文章存档

2023年(9)

2022年(2)

2021年(18)

2020年(7)

2017年(13)

2016年(53)

2015年(55)

我的朋友

分类: C/C++

2016-01-26 11:55:12

下面脚本实现int转化为char后输出

Action()
{
int x;                                            int x=10;                                          int x;
x=10;      --------------------》修改为                ------------》或者修改为      char *y=NULL; 
char *y=NULL;                             char *y=NULL;                                 x=10;
lr_save_int(x,"param");
y=lr_eval_string("{param}");
lr_output_message(y);
return 0;
}

报错:
Action.c (5): illegal statement termination
Action.c (5): skipping `char'
Action.c (5): undeclared identifier `y'
Action.c (5): type error: pointer expected
Action.c (9): operands of = have illegal types `int' and `pointer to char'
Action.c (10): type error in argument 1 to `lr_output_message'; found `int' expected `pointer to char'
d:\\loadrunner11\\scriptctest\\\\combined_scriptCTest.c (5): 6 errors, not writing pre_cci.ci


经过多方调试,原来是赋值语句x=10;顺序问题,赋值语句不能在定义语句char *y=NULL;的前面.
个属于C的基本语法规则,必须把定义放在前面,把算法放后面,不能交叉定义!

附加上char转化为int的函数:
int n=atoi("12345");
lr_output_message("int value is %d",n);
注意如果直接写lr_output_message(n);会报错,lr_output_message默认带的参数是字符型的
阅读(8694) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~