Posts Tagged ‘hex’

Editing a file in hex mode in Vim

Posted: 27th July 2013 by Tim in Linux, Vim
Tags: , , , , , ,

Native Vim doesn’t have a hex editing mode built in, however it is possible to edit a file in hex by converting the file back and forth using xxd. To do this, open your file in Vim and run :%!xxd. From here you can change the hex values and, when you’re done, run :%!xxd -r […]

Imagine that you have read in a hexadecimal string from the command line, a config file or whatever, and you want to use this value in your program. To do this, you need to do a string to integer conversion, but in base 16 since it’s a hexadecimal string. To do this, you can use […]

In C, if you want to convert a string into a number, you can use sprintf(), atoi() or a number of other utility functions. In C++, this can be achieved much more elegantly using std::stringstream objects. But what if you’re string represents a hexadecimal number? This is where stream manipulators come into play. By passing […]