문제

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