Search code examples
c++chexhexdump

Convert Hexdump to string in c


Is there a way to convert a hexdump e.g. aec4d2f3c6a4e70ea6cea074f65812d2a34b180cc92b817edcd867167e7a91c5beb942f0 to a string in c so that every two hexadecimal digits make a char? If so, what?


Solution

  • Reads from stdin and prints to stdout:

    int main() 
    {
        int ch;
        while(scanf("%2x", &ch) == 1)
            putchar(ch);
    }
    

    I think you can modify it easily yourself for your specific source and destination requirements.