Hi,

It says "you are trying to assing a value to something which you can't

assign a value to"

In your case this is pistring[100]

Make it into

char *pistring = 0;

You can't assign a string to a character array.

and don't forget to free or delete pistring (depending whether it was

malloc'ed or new'ed, my guess is the first though).

Regards, Ron AF Greve

http://moonlit.xs4all.nl
"bpazolli" <(E-Mail Removed)> wrote in message

news:(E-Mail Removed) oups.com...

> Ok here we go. I downloaded a pre compiled version of The GNU Multiple

> Precision Arithmetic Library. Now I have created a program with it,

> that I think should work. I have gotten it down to one error. But being

> a noob, I have no idea what it means. Here it is.

>

> Error E2277 main2.cpp 33: Lvalue required in function picalc(int)

>

> Here is my sourcecode.

>

> #include <iostream>

> #include <gmp.h>

> #include <stdio.h>

> using namespace std;

>

> void picalc (int a)

> {

> char pistring[100];

> mpf_t x, y;

> mpf_init (x);

> mpf_init (y);

> double piresult;

> int counter;

> unsigned long int f;

> long int exponent;

> counter = 1;

> a = (a + 1);

> for (long int c=1; c<a; c=c+2)

> {

> cout << "Doing iteration ..." << counter << "\n";

> counter++;

> mpf_set_si (y, c);

> f=1;

> mpf_ui_div (y, f, y);

> mpf_add (x, x, y);

> c=c+2;

> mpf_set_si (y, c);

> mpf_ui_div (y, f, y);

> mpf_add (x, x, y);

> }

> f=4;

> mpf_mul_ui (x, x, f);

> pistring = mpf_get_str (NULL, &exponent, 10, 0, x); // Here is line 33

> no comment

> cout << "The result is ... " << pistring;

> }

>

> int main ()

> {

> int n;

> cout << "Enter the number of iterations?\n";

> cin >> n;

>

> picalc (n);

>

> return (0);

> }

>

> I am sure mpf_get_str is causing the problem becuase I have no idea how

> to use it. Here is the manual entry below.

>

> char * mpf_get_str (char *str, mp exp t *expptr, int base, size t

> n_digits, mpf t op)

> Convert op to a string of digits in base base. base can be 2 to 36. Up

> to n digits digits

> will be generated. Trailing zeros are not returned. No more digits than

> can be accurately

> represented by op are ever generated. If n digits is 0 then that

> accurate maximum number

> of digits are generated.

> If str is NULL, the result string is allocated using the current

> allocation function (see Chapter

> 14 [Custom Allocation], page 84). The block will be strlen(str)+1

> bytes, that being

> exactly enough for the string and null-terminator.

> If str is not NULL, it should point to a block of n digits + 2 bytes,

> that being enough for

> the mantissa, a possible minus sign, and a null-terminator. When n

> digits is 0 to get all

> significant digits, an application won't be able to know the space

> required, and str should be

> NULL in that case.

> The generated string is a fraction, with an implicit radix point

> immediately to the left of the

> first digit. The applicable exponent is written through the expptr

> pointer. For example, the

> number 3.1416 would be returned as string "31416" and exponent 1.

> When op is zero, an empty string is produced and the exponent returned

> is 0.

> A pointer to the result string is returned, being either the allocated

> block or the given str.

>

> Help Me,

> Ben Pazolli

>