Data Type Conversion Functions

上一篇 / 下一篇  2012-06-05 00:07:40 / 个人分类:LoadRunner

Data Type Conversion functions allow you to convert strings from one data type to another. These functions contain the to phrase. Expand the category to view a list of the available functions.

Click one of the following functions for more information:

Function Name

Description

atof

Converts a string to a floating point value.

atoi

Converts a string to an integer value.

atol

Converts a string to a long integer value.

itoa

Converts an integer to a string. Windows only.

strtol

Converts a string to a long integer using a given radix.

 

 

      例子:转换字符串s的初始部分为float数据

       double atof(const char *string);/* Explicit declaration */ //显示声明

       float x;

       char *s = "7.2339 by these hilts or I am a villain else";

       //转换为实型数据并以保留两位小数输出到输出窗口

       x=atof(s);

       lr_output_message("%.2f",x);

 

 

   例子:转换字符串s的初始部分为int数据

    int i;

    char * s = "7 dollars";

    //转换为整型数据

    i = atoi(s);

    lr_output_message ("Price $%d", i);

 

 

   //例子:转换字符串s的初始部分为long数据

    long atol(const char * s); // Explicit declaration  //显示声明

    long i;

    char * s = "2147483647 dollars";

    //转换为长整型

    i = atol(s);

    lr_output_message ("Price $%ld", i);

 

例子:转换字整型把数据卫字符串数据

int i=56;

char filename[64].file_index[32];

if(!itoa(i,file_index,10)

lr_output_message("Cannot convert i to ascii char");

else {

sprintf(filename,"log_%s.txt",file_index);

lr_output_message("New file name %s",filename);

}

 


TAG:

 

评分:0

我来说两句

Open Toolbar