I need to take an integer value and convert it so that when it is represented in hexadecimal, the digits are reversed. For instance:
Dim a As Integer = &H4321Dim a_changedorder As Integer = ReverseHexDigits(a)Console.Writeline(a_changedorder.ToString("X4")) ' Should output 1234
How can I implement a
ReverseHexDigits method that works like that?
As a second example,
&H4F2A should become
I am trying to convert a string such as "0x7ffd01767a60" to hexadecimal so I can compare pointers. Not sure if this is the best decision.
I am doing this:
char *address = "0x7ffd01767a60"; strtol(address,NULL,16); printf("%lp",address);
And I am getting this: 0x7ffd01764120
EDIT: It seems I was printing the string address ignoring the function return. Thanks Jens! and schlenk.
SOLVED! This is what I do
char *address = "0x7ffd01767a60"; void *p; unsigned long int address_hex = strtol(address,NULL,16); p = (void*) address_hex; printf("%p",p);
printf prints the same memory address.
This question already has an answer here:
How do I convert a
byte to a
string? Every time I attempt it, I get
instead of the value.
Also, how do I get the value in Hex instead of a decimal?
I'm working on a project in PHP, and i need to get a list of all strings contained in a executable PE file, like some desktop programs do. Here is a screenshot of what i need that the file returns:
I can have the HEX dump of the file, and the strings are there, but i don't know how to extract them. Maybe with regex, idk...
I could make a program in C that return the strings to the PHP script, but i want to make it using PHP, because i'll upload the script to a host, and maybe i cannot use commandline or something like this.
Any tips about this?
I was trying to convert the below C code to Java. I am getting the below exception while doing so. What am I doing wrong here? Please advice.
Exception in thread "main" java.util.IllegalFormatConversionException: x != java.lang.Stringat java.util.Formatter$FormatSpecifier.failConversion(Unknown Source)at java.util.Formatter$FormatSpecifier.printInteger(Unknown Source)at java.util.Formatter$FormatSpecifier.print(Unknown Source)at java.util.Formatter.format(Unknown Source)at java.util.Formatter.format(Unknown Source)at java.lang.String.format(Unknown Source)at com.kube.rfidscannertest.MainScannerTest.printEpc(MainScannerTest.java:68)at com.kube.rfidscannertest.MainScannerTest.main(MainScannerTest.java:42)
Below is the C code.
printf("%04X", (((epc[i] & 0xFF00) >> 8) | ((epc[i] & 0xFF) << 8)));
Below is how I am trying to covert it into Java.
String.format("%04X ", Integer.toHexString((((data[i] & 0xFF00) >> 8) | ((data[i] & 0xFF) << 8))).replace(' ', '0')).concat(strData);
Please note that epc and data are integer arrays.