I am using the GMP multiple precison package.
I need to input very large integers as strings, for example
Code:
mpz_init_set_str(x,"1234567890",10)
will set x to that large integer in quotes (10 gives the base.)
I want to be able to have the user enter the value, so I did something like:
Code:
#include <string>
#include <gmpxx.h> // GMP
string num;
std::cin >> num;
mpz_init_set_str(x,num,10)
but this causes g++ to give the following error:
error: cannot convert `std::string' to `const char*' for argument `2' to `int __gmpz_init_set_str(__mpz_struct*, const char*, int)'
Any ideas how to input a data type that will work?
I am using Ubuntu on an AMD64.
Thanks!