readfile

 1 /*
 2  * hello.c
 3  *
 4  *  Created on: 2015年7月9日
 5  *      Author: 10171939
 6  */
 7
 8 #include<stdio.h>
 9 #include<string.h>
10 #include<strings.h>
11
12 int main()
13 {
14     char filename[] = "e:\\DCX81_MOD_UART.info";
15     char CMBS_Release[] = "CMBS Release ";
16     char CMBS_TARGET_API_Version[] = "CMBS TARGET API Version ";
17
18     char strValue[12] = { 0 };
19     FILE *fp;
20     char StrLine[1024];
21
22     if ((fp = fopen(filename, "r")) == NULL)
23     {
24         printf("error!\n");
25         return -1;
26     }
27
28     while (!feof(fp))
29     {
30         memset(StrLine, 0, 1024);
31         fgets(StrLine, 1024, fp);
32         if (strstr(StrLine, CMBS_Release) != NULL)
33         {
34             strcpy(strValue, StrLine + strlen(CMBS_Release));
35             printf("%s: %s", CMBS_Release, strValue);
36         }
37         else if (strstr(StrLine, CMBS_TARGET_API_Version) != NULL)
38         {
39             strcpy(strValue, StrLine + strlen(CMBS_TARGET_API_Version));
40             printf("%s: %s", CMBS_TARGET_API_Version, strValue);
41         }
42         else
43         {
44             continue;
45         }
46
47     }
48
49     fclose(fp);
50     return 0;
51
52 }
时间: 2024-08-29 16:52:19

readfile的相关文章

php 读取文件readfile

<?php //读取文件 echo readfile('aa.txt'); ?>

Php中 readfile() 文件大小如何设置?

本文和大家分享的主要是php readfile() 文件大小设置相关内容,一起来看看吧,希望对大家学习php有所帮助. 使用PHP ZipArchive生成的压缩包,小的压缩包都能下载,今天遇到个150M以上的就报404错误,第一想到的就是文件大小超出了PHP默认设置,修改方法有两个: php.ini:memory_limit memory_limit是设置内存限制的,如果使用readfile()读取文件就会和这个有关,直接修改这个值保存后重启php-fpm即可. memory_limit =

C/C++ 文件操作之CreateFile、ReadFile和WriteFile

1. CreateFile 这个函数的功能是创建或者打开一个文件或者I/O设备,通常使用的I/O形式有文件.文件流.目录.物理磁盘.卷.终端流等.如执行成功,则返回文件句柄. INVALID_HANDLE_VALUE 表示出错,会设置 GetLastError . 函数的声明定义: HANDLE WINAPI CreateFile( _In_ LPCTSTR lpFileName, _In_ DWORD dwDesiredAccess, _In_ DWORD dwShareMode, _In_o

readfile &amp; file_get_contents异同

记录一下:应用memcache时,准备把整个文件缓存到内存中,遇到了比较奇怪的事情,因为最初使用readfile来读取文件,结果这个函数返回一个字节数,而不是一个字符串,于是文件没办法再输出,最后使用file_get_contents解决问题. file_get_contents -- 将整个文件读入一个字符串 说明 string file_get_contents ( string filename [, bool use_include_path [, resource context [,

lua 的 WriteFile 和 ReadFile

lua 的 ReadFile 和 WriteFile 注意: lua 代码中的 string 可以包含二进制数据 string.len(str) 不会被 '\0' 截断 从 lua 传入 c 时: 需要传入包含二进制数据的 string 和数据的 size, size 用 string.len(str) 来计算 从 c 传入 lua 时: 应该使用 lua_pushlstring 而不是 lua_pushstring, lua_pushstring 内部使用 strlen() 来计算数据的长度,

CreateFile,WriteFile,ReadFile

注意: CreateFile 跟 fopen 不同,打开文件时不区分 文本方式 或 二进制 方式 ReadFile 或 WriteFile 都是对二进制数据进行操作 HANDLE WINAPI CreateFile( __in LPCTSTR lpFileName, // 文件路径 __in DWORD dwDesiredAccess, // 访问权限,GENERIC_READ | GENERIC_WRITE __in DWORD dwShareMode, // 共享模式,NULL | FILE

CreateFile,ReadFile等API详解(或者说MSDN的翻译)

一.*****CreateFile***** 这个函数可以创建或打开一个对象的句柄,凭借此句柄就可以控制这些对象:控制台对象.通信资源对象.目录对象(只能打开).磁盘设备对象.文件对象.邮槽对象.管道对象.    函数原型:HANDLE CreateFile(LPCTSTR lpFileName,                         // file name对象路径名DWORD dwDesiredAccess,                      // access mode控

CreateFile、WriteFile、ReadFile

读写文件每一个软件开发显目必定涉及的工作.CreateFile函数用于创建对应的文件句柄,WriteFile函数是用来写数据到文件,ReadFile函数是从文件里读取数据出来. CreateFile 该函数用于生成设备(文件)的对应句柄(HANDLE). //CreateFile函数声明 HANDLE CreateFile( LPCTSTP lpFileName, //文件名 DWORD dwDesiredAccess, //访问方式 DWORD dwShareMode, //共享模式 LPSE

readfile() 函数

定义和用法 readfile() 函数输出一个文件. 该函数读入一个文件并写入到输出缓冲. 若成功,则返回从文件中读入的字节数.若失败,则返回 false.您可以通过 @readfile() 形式调用该函数,来隐藏错误信息. 语法 readfile(filename,include_path,context) 参数 描述 filename 必需.规定要读取的文件. include_path 可选.如果也想在 include_path 中搜索文件,可以使用该参数并将其设为 true. contex

WriteFile和ReadFile函数

#include <stdio.h> #include <Windows.h> #define BUF_SIZE 256 int main() { HANDLE hFileRead; DWORD nIn; CHAR buffer[BUF_SIZE]; hFileRead = CreateFile("book.txt", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMA