Dumping memory to file

前端 未结 5 588
囚心锁ツ
囚心锁ツ 2021-01-05 11:57

I\'ve got a part of my memory that I want to dump to a file. One reason is to save the information somewhere, and another is to read it again when my program restarts.

5条回答
  •  时光取名叫无心
    2021-01-05 12:11

    You can use

    size_t fwrite ( const void * ptr, size_t size, size_t count, FILE * stream );
    

    function.

    ptr - pointer to you memory segment.
    size - size of memory to write.
    stream - file you writing to.
    

    Will my "datastructures" survive as "charachters", or do I need to write it in some sort of binary / hexa data-mode? Or is it a stadard way of doing this?

    when you open file - use 'b' character in "mode" param

提交回复
热议问题