With the following

DIM a AS INTEGER
a = 10
OPEN "myFile" FOR BINARY AS #1
PUT #1, 1, a
CLOSE #1

I get a file (myFile) with two bytes (using QB64). The first byte is indeed 0A, but there is a second byte 00.

How can I create a file with just one byte?

有帮助吗?

解决方案 2

Try this

DIM a AS _UNSIGNED _BYTE
a = 10
OPEN "myFile" FOR BINARY AS #1
PUT #1, 1, a
CLOSE #1

It seems like INTEGER is 2 bytes.

其他提示

Snip to write a byte to file:

DIM B AS STRING * 1
x = 10
B = CHR$(x)
OPEN "myfile" FOR BINARY AS #1
PUT #1, 1, B
CLOSE #1
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top