Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
I want to read and write numbers between files and memory ...
I want to read and write numbers between files and memory in a byte-at-a-time way, not as formatted characters the way fprintf and fscanf do. How can I do this?
✍: Guest
What you're trying to do is usually called ``binary'' I/O. First, make sure that you are calling fopen with the "b" modifier ("rb", "wb", etc.; Then, use the & and sizeof operators to get a handle on the sequences of bytes you are trying to transfer. Usually, the fread and fwrite functions are what you want to use;Note, though, that fread and fwrite do not necessarily imply binary I/O. If you've opened a file in binary mode, you can use any I/O calls on it if you've opened it in text mode, you can use fread or fwrite if they're convenient.
Finally, note that binary data files are not very portable;
2015-09-24, 1171👍, 0💬
Popular Posts:
How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters? Unicode requires 1...
What are urlencode() and urldecode() functions in PHP? string urlencode(str) - Returns the URL encod...
How To Export Data to a CSV File? - Oracle DBA FAQ - Introduction to Oracle SQL Developer If you wan...
Do You Know the Book "JUnit in Action"? You should know this book. It received some good reviews. Ti...
How To List All Values of Submitted Fields? - PHP Script Tips - Processing Web Forms If you want lis...