`
febird
  • 浏览: 254256 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

memory FILE in C

    博客分类:
  • C++
阅读更多

<script>function StorePage(){d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&u='+escape(d.location.href)+'&c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();}</script>

一直希望有个可以像 FILE* 一样使用的 memory file,正好,今天,在linux的stdio.h中找到了这个东西。

#define _GNU_SOURCE
#include <
stdio.h>

FILE *fmemopen(void *buf, size_t size, const char *mode);

FILE *open_memstream(char ** ptr, size_t *sizeloc) ;

详细说明:http://linux.die.net/man/3/open_memstream

fmemopen 有用之处主要在于从内存中读取,使用 fscanf。当然也可以写,如果是为了写,并且随后再读,可以将 buf 和 size指定为 NULL,0,这样写时会自动增加内存。

open_memstream 就主要用于写了,比如生成sql语句:

0
0
分享到:
评论

相关推荐

    Direct Memory Access in Linux.doc

    1. **Using `/dev/mem`**: The simplest method is to use the `/dev/mem` device file, which provides access to the physical memory. However, this approach has limitations, as the memory accessed in this ...

    BURNINTEST--硬件检测工具

    - Enhanced the mechanism to report memory hardware errors in the Memory torture test. Release 5.3 build 1033 WIN32 release 1 October 2008 - Changes to correct a BurnInTest crash problem on some ...

    Intergraph Standard File Formats (Element Structure)

    If the file is "indexed" an additional 12 bytes per element is kept in memory after a pre-scan, but this isn't required. Does DGNLib include code to draw DGN elements? No, but there is a document ...

    Secure.Coding.in.C.and.Cplusplus.2nd.Edition.0321822137.epub

    Secure Coding in C and C++, Second Edition, identifies and explains these root causes and shows the steps that can be taken to prevent exploitation. Moreover, this book encourages programmers to adopt...

    【Android4.4.4.4_r1系统源码】DexFile.h

    * It's generally assumed that the DEX file will be stored in shared memory, * obviating the need to copy code and constant pool entries into newly * allocated storage. Maintaining local pointers to...

    Quartus II工程文件的后缀含义.docx

    1. AHDL Include File (.inc):AHDL 包含文件,用于包含其他 AHDL 文件中的代码。 2. ATOM Netlist File (.atm):ATOM 网表文件,用于描述数字电路的网表结构。 3. Block Design File (.bdf):块设计文件,用于...

    建站过程中php.ini及config.inc.php

    在构建网站的过程中,`php.ini` 和 `config.inc.php` 是两个至关重要的配置文件,它们分别负责管理和调整PHP运行环境的参数以及数据库连接设置。理解并掌握这两个文件的使用是确保网站正常运行和优化性能的基础。 `...

    vld-2.5.1-setup.exe

    It's a very effective way to quickly diagnose, and fix, memory leaks in C/C++ applications. The main difference between the CRT Debug Library and VLD, is that Visual Leak Detector shows you the ...

    libgcc_s_dw2-1.dll另一种版本

    After extracting your zip-file, place the extracted DLL-file in the directory of the program that is requesting the file. Make sure to use a 32bit DLL-file for a 32bit program, and a 64bit DLL-file ...

    Debugging Malloc Lab: Detecting Memory-Related Errors

    There are also two optional functions in the debugmalloc.c file that you can implement: void PrintAllocatedBlocks(); int HeapCheck(); PrintAllocatedBlocks should print out information about all ...

    ICC8051 Micro Series 8051 C-Compiler V4.10A/DOS

    Sourcefile: 'C' source file with default extension: .c Environment: QCC8051 Options (specified order is of no importance): -o file Put object on: &lt;file&gt; -Oprefix Put object on: &lt;prefix&gt; &lt;source&gt; -b ...

    微软内部资料-SQL性能优化2

    A hard page fault results in a read from disk, either a page file or memory-mapped file. A soft page fault is resolved from one of the modified, standby, free or zero page transition lists. Paging is...

    C.Programming.Step.By.Step.Beginners.To.Experts.Edition.B011EXMV7Q

    File Handling In C. Chapter 13. Miscellaneous Topics. Chapter 14. Storage Class. Chapter 15. Algorithms. Chapter 16. Unsolved Practical Problems. Chapter 17. PART-II-120+ Practical Code Chapter-Wise....

    绿色版PocketDOS 和 绿色版TC3.0

    GETOPT C - Parses options in command line GREP2MSG C - Example program for Turbo C++ filters HELLO C - Example Turbo C++ program INTRO1 CPP - Example program from User's Guide INTRO10 CPP - ...

    Turbo C 2.00[DISK]

    o Because of the limited memory available in the Tiny model, it no longer supports graphics functions. o The Version 1.5 graphics drivers (*.BGI) are not compatible with the Version 2.0 graphics ...

    C标准库源代码(学习C/C++必备)

    C标准库源代码\CRUNTIME.INC C标准库源代码\CSCANF.C C标准库源代码\CSETJMP C标准库源代码\CSIGNAL C标准库源代码\CSTDARG C 标准库源代码\CSTDDEF C标准库源代码\CSTDIO C标准库源代码\CSTDLIB C标准库源代码\...

    Objective-C Programming The Big Nerd Ranch Guide 2nd Edition

    When you run a program, a file is copied from the file system into memory (RAM), and the instructions in that file are executed by your computer. Those instructions are inscrutable to humans. So, ...

    C Programming

    The document explains file handling in C, which involves reading from and writing to files: - **When Do We Use Files?**: Discussion on scenarios where file handling is necessary. - **Streams and ...

Global site tag (gtag.js) - Google Analytics