Question

junk.writeBytes("Henry McCollum");
junk.writeInt = 9304029494;
junk.writeBytes("Toronto");

If the above example were all ints, I could just set the record size to be equal to 12(since 3 ints * 4 bytes = 12), but how would I know how big the 2 string are for name and city?

Était-ce utile?

La solution

You would need to record the size of the string:

junk.writeInt("Henry McCollum".length());
junk.writeBytes("Henry McCollum");
//and so on

When reading read the int and then the correct number of bytes specified by that int.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top