Search code examples
cstringtype-conversiongmp

Convert string to mpz_t in C


Is there a method to convert a string, or in my case a char array, to the mpz_t type from gmplib. Is there something similar to the sscanf function? Anything for the C programming language would be relevant.


Solution

  • In the online manual: https://gmplib.org/manual/Assigning-Integers.html#Assigning-Integers

    The function mpz_set_str is probably what you are looking for.