I don't think that is the problem.  The line mpz_array_init (array, 
10000, 1); makes it an array.  If you do mpz_t array[10000] it will 
make errors.

Thanks,
Plano9

--- In [email protected], "Paul Herring" <[EMAIL PROTECTED]> wrote:
> 
> From: plano9 [mailto:[EMAIL PROTECTED] 
> 
> >I'm unfamilar with GMP's snytaxes, so I need some help fixing 
these 
> >two errors.
> >Both errors are "error C2107: illegal index, indirection not 
allowed"
> >on lines 17 and 26
> >
> >The source code for the program is:
> >
> >//This program is a primitive implementation of a factoring sieve
> 
> Presumably, since you didn't indicate which line was which, this 
was
> line 1
> 
> >
> >#include <iostream.h>
> 
> .h files in C++ are depreciated. Don't use them unless you really 
must.
> 
> >#include "gmp.h"
> >
> >int main()
> >{
> >     mpz_t n, N, k, var, hold, array;
> >     short prime=1;
> >     mpz_set_ui(n, 100);
> >     mpz_set_ui(k, 2);
> >     mpz_sqrt(N, n);
> >     mpz_array_init (array, 10000, 1);
> >     while (k <= N)
> >     {
> >             mpz_cdiv_r(hold, n, k);
> >             if (array[k] == 0 && hold == 0)
> 
> Making this line 17
> 
> >             {
> >                     mpz_cdiv_q (hold, n, k);
> >                     cout << k << " * " << hold << "; ";
> >                     prime=0;
> >                     mpz_set (var, k);
> >                     while (var < N)
> >                     {
> >                             mpz_add(var, var, k);
> >                             mpz_set_ui(array[var], 1);
> 
> And this 27.
> 
> You declare on line 8:
> 
>       mpz_t n, N, k, var, hold, array;
> 
> While you may be calling it an array, is it really one?
> 
> From what I can tell from the few pages I googled, mpz_t is a type 
that
> is substitutable for an integer. Making your line similar to :
> 
>       int n, N, k, var, hold, array;
> 
> You cannot use the variable delcared as 'array' here as an actual 
array.
> You need something similar to either:
> 
>       mpz_t n, N, k, var, hold, array[10];
> 
> or
> 
>       mpz_t n, N, k, var, hold;
>       mpz_t* array;
>       array = new mpz_t[10];
> 
> --
> PJH
> 
> "Consistently separating words by spaces became a general custom 
about
> the tenth century A.D., and lasted until about 1957, when FORTRAN
> abandoned the practice." -- Sun FORTRAN Reference Manual 
> 
> 
> 
> Alderley plc, Arnolds Field Estate, The Downs, Wickwar, 
Gloucestershire, GL12 8JD, UK
> Tel: +44(0)1454 294556 Fax: +44 (0)1454 299272
> 
> Website : www.alderley.com  Sales : [EMAIL PROTECTED] Service : 
[EMAIL PROTECTED]
> 
> This email and its contents are confidential and are solely for 
the use of the intended recipient. If you are not the original 
recipient you have received it in error and any use, dissemination, 
forwarding, printing or copying of this email is strictly 
prohibited. Should you receive this email in error please 
immediately notify [EMAIL PROTECTED]
> 
> This email has been scanned for viruses, however you should always 
scan emails with your own systems prior to opening.





------------------------ Yahoo! Groups Sponsor --------------------~--> 
$4.98 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/Q7_YsB/neXJAA/yQLSAA/EbFolB/TM
--------------------------------------------------------------------~-> 

>-----------------------------------------~-~>
CHECK THE ARCHIVE BEFORE POSTING!!!! Archive is available at 
http://www.eScribe.com/software/C-Paradise/

>------------------------------------------_->


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/C-Paradise/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to