| | |
read & write Binary data
![]() |
•
•
•
•
Originally Posted by mhm_ra
i need to r write binary(hexadecimal) values into a text file then read this data and manipulate it as a number
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <fstream> void write(const char *filename) { std::ofstream file(filename); for ( int i = 100; i < 110; ++i ) { file << std::hex << i << '\n'; } } void read(const char *filename) { std::ifstream file(filename); int value; while ( file >> std::hex >> value ) { std::cout << "value = " << value << '\n'; } } int main() { static const char filename[] = "file.txt"; write(filename); read(filename); return 0; } /* my output value = 100 value = 101 value = 102 value = 103 value = 104 value = 105 value = 106 value = 107 value = 108 value = 109 */ /* file.txt 64 65 66 67 68 69 6a 6b 6c 6d */
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
![]() |
Similar Threads
- image long binary data (ASP)
- Need help with Binary files and data types in VB6 (Visual Basic 4 / 5 / 6)
- Reading binary data from a file and writing it (Visual Basic 4 / 5 / 6)
- Login and retrieve user data from database (ASP.NET)
- Binary data in app.config (C#)
Other Threads in the C++ Forum
- Previous Thread: read data from file
- Next Thread: Debug
| Thread Tools | Search this Thread |
api array based binary bitmap business c++ c/c++ char class classes code coding commentinghelp compile console conversion count decide delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez graph guess gui homeworkhelp homeworkhelper iamthwee ifpug ifstream incrementoperators infinite input int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem proficiency program programming project python random read recursion reference rpg string strings temperature template templates test text text-file tree url variable vector video win32 windows winsock word wordfrequency wxwidgets






