直接代码展示:

char* testfn()

{

int count, total = 0;

char * buffer = NULL;

int filelenth = 0;

long file_stream;

char * filename = "F:\\test.txt";

if ((file_stream = fopen(filename, "r")) == NULL )

{

lr_error_message ("Cannot open %s", filename);

return NULL;

}

fseek(file_stream,0,2); //定位到文件末尾

filelenth = ftell(file_stream); //获取文件总长度

fseek(file_stream,0,0); //定位文件开头

buffer = (char *)malloc(filelenth); //动态分配内存

count = fread(buffer, sizeof(char), filelenth, file_stream); //读取文件

lr_output_message ("%d bytes read", count);

lr_output_message ("content read = %s", buffer );

if (fclose(file_stream))//关闭文件

{

lr_error_message ("Error closing file %s", filename);

}

return buffer;

}

Action()

{

char *pt = NULL;

pt = testfn();

lr_save_string(lr_eval_string(pt), "param");

lr_output_message("value of param: %s",lr_eval_string("{param}"));

free(pt); //释放内存

return 0;
}

运行结果:

Loadrunner脚本篇——从文件中读取内容并参数化的更多相关文章

  1. 从Excel文件中读取内容

    从Excel文件中读取内容 global::System.Web.HttpPostedFileBase file = Request.Files["txtFile"]; strin ...

  2. python3 简单实现从csv文件中读取内容,并对内容进行分类统计

    新手python刚刚上路,在实际工作中遇到如题所示的问题,尝试使用python3简单实现如下,欢迎高手前来优化import csv #打开文件,用with打开可以不用去特意关闭file了,python ...

  3. Python从文件中读取内容,包含中文和英文

    读取文件内容使要和保存文件时的格式一致 以UTF-8格式保存文件,如: 读取: 在.py起始行写入:#-*- coding:utf-8 -*- filename = raw_input(u" ...

  4. FileWriter实现从一个文件中读取内容并写到另一个文件中

    FileWriter和FileOutputStream都是向文件写内容,区别是前台一次写一个字符,后者一次写一个字节 package com.janson.day20180827; import ja ...

  5. 用python脚本 从xls文件中读取数据

    导入 xlrd 第三方模块 import xlrd data = xlrd.open_workbook('test.xlsx') # 打开xls文件 table = data.sheets()[0] ...

  6. shell 脚本,提取文件中的内容

    使用awk.cut.sed.if.while 等 awk.cut.sed还是很重要的 这是后来修改的,可以完成 #!/bin/bash #conver formatFILE=mobile_dpi.ru ...

  7. 在java中读取文件中的内容

    package shi; import java.io.*; public class wenjianIO { public static void main(String agrs[]){ File ...

  8. Python3 将configparser从ini文件中读取的内容转换成字典格式

    因为写脚本的用到了,所以研究了下怎么将configparser从ini文件中读取的内容转换成字典格式. 整理一下,希望能对大家有帮助. 从http://stackoverflow.com/questi ...

  9. 归纳从文件中读取数据的六种方法-JAVA IO基础总结第2篇

    在上一篇文章中,我为大家介绍了<5种创建文件并写入文件数据的方法>,本节我们为大家来介绍6种从文件中读取数据的方法. 另外为了方便大家理解,我为这一篇文章录制了对应的视频:总结java从文 ...

随机推荐

  1. c++ 如何使用第三方的library

    感谢以下参考资料: 关于如何使用第三方的库: http://stackoverflow.com/questions/21942545/how-to-install-third-party-librar ...

  2. the method getcontextpath() from the type httpservletrequest refers to the missing type string

    导入项目的时候容易报出这个错误,主要因为JRE(jdk版本不一致). 解决方法:就是重新配置路径,配置你机器上安装的jdk. 右击该出错项目→ Build Path → Configure Build ...

  3. iOS 学习笔记一【屏幕截图,并显示当前View】

    // 直接上代码: // // ViewController.h // 屏幕截图测试 // // Created by 博爱之家 on 15/11/11. // Copyright © 2015年 博 ...

  4. CPU亲和力

    http://blog.chinaunix.net/uid-27714502-id-3515874.html http://www.tuicool.com/articles/I7NFzy http:/ ...

  5. hadoop_百科

    一.发音是:[hædu:p]. 二.简介:Hadoop是一个由Apache基金会所开发的分布式系统基础架构.用户可以在不了解分布式底层细节的情况下,开发分布式程序.充分利用集群的威力进行高速运算和存储 ...

  6. abp的开发20180425

    指定默认语言. mvc5 在Global中的 protected override void Application_BeginRequest(object sender, EventArgs e) ...

  7. Ordering Tasks UVA - 10305 图的拓扑排序

    John has n tasks to do. Unfortunately, the tasks are not independent and the execution of one task i ...

  8. 第一百八十二节,jQuery-UI,知问前端--日历 UI

    jQuery-UI,知问前端--日历 UI 学习要点: 1.调用 datepicker()方法 2.修改 datepicker()样式 3.datepicker()方法的属性 4.datepicker ...

  9. python 爬虫实战1 爬取糗事百科段子

    首先,糗事百科大家都听说过吧?糗友们发的搞笑的段子一抓一大把,这次我们尝试一下用爬虫把他们抓取下来. 本篇目标 抓取糗事百科热门段子 过滤带有图片的段子 实现每按一次回车显示一个段子的发布时间,发布人 ...

  10. js金钱分割,正则

    ``` var test1 = '1234567890'var format = test1.replace(/\B(?=(\d{3})+(?!\d))/g, ',')"1,234,567, ...