下面脚本实现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默认带的参数是字符型的
阅读(8852) | 评论(0) | 转发(0) |