This is the kind of situation when using a library is recommended.
Using GMP, you can do these conversions (gmp.c):
#include <stdio.h>
#include <stdlib.h>
#include <gmp.h>
int main(int argc, char *argv)
{
// From string
char *s ="199999999999999999999999999999999999999";
mpz_t i;
// To big number, using GMP
// 10 here means base 10.
mpz_init_set_str(i, s, 10);
// Just to test if s is 128 bits long
printf("%s can be represented with %d digits in base 2\n",s, mpz_sizeinbase(i, 2));
// Then you can print it in hex
gmp_printf("%#32ZX\n", i);
// Or convert it back to int[4]
unsigned int a[4];
mpz_export(&a, NULL, 1, 4, 0, 0, i);
for(int x=0;x<4;x++)
printf("%X\n", a[x]);
mpz_clear(i);
return 0;
}
Output:
199999999999999999999999999999999999999 can be represented with 128 digits in base 2
0X96769950B50D88F41314447FFFFFFFFF
96769950
B50D88F4
1314447F
FFFFFFFF
I tested this code on a 32 bit Linux system. Please pay attention to different int sizes and endianess on different platforms.
You probably want the result in big endian, if so, just change mz_export to:
mpz_export(&a, NULL, 1, 4, 1, 0, i);
To compile the example, don't forget to install gmp and to add -lgmp -std=c99 on gcc command line parameters.
On Ubuntu, you can install gmp with:
sudo apt-get install libgmp-dev
And compile the example, gmp.c:
gcc gmp.c -o gmp -lgmp -std=c99
This code can be a good start for your conversions. You can also initialize i to be a fixed 128 bit number (using init functions of GMP), just in case your big number starts with zeros.