Importing from an Input of Delphi

Jonathan A. Zylstra jon at jzylstra.com
Sun Mar 27 23:31:40 CEST 2005


Wilhelm Korrengk wrote:

>Hello,
>I don`t really like to load gmp into Delphi as far as it is already linked to 
>my library so far.
>
>So I decided to use mpz_set_str(mpz_t, string), which means that I will just 
>give it a string of  "number^number"  (99^1 or 32^100 .... )
>
>Anyway my compiler alway tells me:
>
>--------
>error: cannot convert `std::string' to `const char*' for argument
>   `2' to `int __gmpz_set_str(__mpz_struct*, const char*, int)'
>--------
>
>  
>
That's because std::string is  a C++ class, and needs to be specifically 
converted to a C style string.
So, replace x with x.c_str(), and try again.
The manual this is found in is  a C++ manual, not the GMP manual.

Jonathan A. Zylstra

>CODE:
>
>-------
>bool primcheck_1 ( string x ) {
>
>
> mpz_t n;
> mpz_init(n);
> 
> mpz_set_str(n, x, 0);
>
>------
>
>I`m sorry but the manual did not help me up that far!
>
>Thanks in adance!
>Wilhelm Korrengk
>_______________________________________________
>gmp-discuss mailing list
>gmp-discuss at swox.com
>https://gmplib.org/mailman/listinfo/gmp-discuss
>
>  
>



More information about the gmp-discuss mailing list