What is binary data?

gcc 4.6.0

What does binary data look like? Are all 1 and 0.

I was just wondering when I was talking with another programmer about copying strings and binary data.

I usually use strcpy / strncpy functions to copy strings and memcpy / memmove to copy binary data. However, I'm just wondering what that looks like?

Thanks so much for any suggestions,

+3
source share
5 answers

" " , (, '\0'). , strcpy() strncpy(), , , , memcpy() memmove(), , .

+5

, . ASCII:

jcomeau@intrepid:~$ xxd /bin/bash | head -n 10
0000000: 7f45 4c46 0101 0100 0000 0000 0000 0000  .ELF............
0000010: 0200 0300 0100 0000 5021 0608 3400 0000  ........P!..4...
0000020: 345c 0c00 0000 0000 3400 2000 0800 2800  4\......4. ...(.
0000030: 1c00 1b00 0600 0000 3400 0000 3480 0408  ........4...4...
0000040: 3480 0408 0001 0000 0001 0000 0500 0000  4...............
0000050: 0400 0000 0300 0000 3401 0000 3481 0408  ........4...4...
0000060: 3481 0408 1300 0000 1300 0000 0400 0000  4...............
0000070: 0100 0000 0100 0000 0000 0000 0080 0408  ................
0000080: 0080 0408 c013 0c00 c013 0c00 0500 0000  ................
0000090: 0010 0000 0100 0000 c013 0c00 c0a3 1008  ................

:

jcomeau@intrepid:~$ convert -size 640x$(($(stat -c %s /bin/bash)/640)) \
 -depth 8 gray:/bin/bash /tmp/bash.png
jcomeau@intrepid:~$ firefox /tmp/bash.png

enter image description here

+16

- , , . , , , , .

, .

+8

Binary data is simply data encoded in binary form. To better understand what the contents of a binary file look like, you will need a hex editor, such as the Hiew editor for Windows or hexedit for Linux.

+3
source

These are all ones and zeros. But those and zeros live differently on your computer. The CPU sees those and zeros differently from DRAM, and both are encoded differently on the hard drive.

0
source

All Articles