void poly_diff

This is a discussion on void poly_diff within the C Programming forums, part of the General Programming Boards category; When I try to compile this, I get a warning: In function 'poly_diff': poly.c:206: warning: comparison between pointer and integer ...

  1. #1
    Registered User
    Join Date
    Nov 2010
    Posts
    24

    void poly_diff

    When I try to compile this, I get a warning:
    In function 'poly_diff':
    poly.c:206: warning: comparison between pointer and integer
    Code:
    void
    poly_diff(int *d, double **p) {
    
      /*
       * poly_diff(int *d, double **p)
       * differentiates the polynomial (d, p)
       *
       * Example:
       *
       *   int d1 = 4;
       *   double *p1;
       *   p1 = poly_create(d1);
       *   // set polynomial to 1 - 2.5 x^2 - x^4
       *   p1[0] = 1; p1[2] = 2.5; p1[4] = -1;
       *   poly_diff(&d1, &p1);
       *
       * will set (d, p) to the polyomial - 5 x - 4 x^3.
       *
       * Be sure to handle the case when polynomial is a constant!
       */
    
      /* WRITE YOUR CODE HERE */
    
      int counter;
            for(counter=0; counter<(*d); counter++){
                            if(counter==0){
                                    *(*((p)+counter))=*(*((p)+(counter+1)));
                            }
                            if(counter==1){
                                    (*(*((p)+counter)))=(*(*((p)+(counter+1))))*(dou
    ble)2;
                            }
                            if(counter==2){
                                    (*(*((p)+counter)))=(*(*((p)+(counter+1))))*(dou
    ble)3;
                            }
                            if(counter==3){
                                    (*(*((p)+counter)))=(*(*(((p)+(counter+1)))))*(d
    ouble)4;
                            }
            }
            
            d=(d-1);
          
            for(counter=0;counter<(d+1); counter++){
                    printf("%d  ", *(p+counter));
            }
    
    }

  2. #2
    Registered User
    Join Date
    May 2010
    Location
    Naypyidaw
    Posts
    1,314
    Code:
            for(counter=0;counter<(d+1); counter++){
    Your compiler tells you which line. and you can't find out?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Matrix operations using objects
    By circuitbreaker in forum C++ Programming
    Replies: 7
    Last Post: 05-04-2010, 08:53 AM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Replies: 3
    Last Post: 05-13-2007, 08:55 AM
  4. msvc just ate one of my source files
    By Eber Kain in forum C++ Programming
    Replies: 6
    Last Post: 07-01-2004, 05:40 AM
  5. Half-life SDK, where are the constants?
    By bennyandthejets in forum Game Programming
    Replies: 29
    Last Post: 08-25-2003, 11:58 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21