Writing to a file is more than just text

I could always read and write basic text files in C ++, but so far no one has discussed much more.

My question is:

If I myself develop a file type for use by the application, I also create, how would I start writing data to a file and save the layout, formatting, etc.? Are there any standards, or does it depend only on the creativity of the programmer?

+3
source share
14 answers

You basically have to come up with your own file format and write binary data. You can also serialize your object model and write the output to a file, but this is usually less efficient.

xml ( ) . , , , .

+3

, . Joel : 97-2003 - 349 .

, - , API, . , " " , . , , , ..

+3

, . , xml, , , , .

+2

, , , (, XML JSON).

() .

+2

, . , , , . (OOXML, OpenDocument) .

.

. , , , , .

+2

. wotsit.org . . , .BMP .

- , SQL-.

+1

, . , , .

0

. , , , Oracle, . (, Excel vs Openoffice, Oracle vs MySQL ..), , .

, , !

0

xml (- , ) . , ODF

0

, ( ), . - endianess, (x86 - PPC ).

, , , , .

0

/ , . / XML, . , . Boost , .

/Allan

0

, , - . BOOST:: Serialization, Google Protocal Buffers . , ( ), , , .

, , , . . fopen, fread, fwrite fclose .

0

- " ",

-------
|index|
-------
|data |
-------

, .

, . , , (.. ).

typedef struct {
  size_t offset
  size_t size
} Index

typedef struct {
  int  ID
  char First[20]
  char Last[20]
  char *RandomInfo
} Data

, 50 , 50 50 . 50 , 50 .

, 50 , , "" .

(fopen, fread, fwrite, fclose, ftell) / .

(, )

0

1985, , IFF, . - , RIFF WAV-. ( , TIFF - .) PNG, .

0

Source: https://habr.com/ru/post/1696976/


All Articles