DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 6 of 6

Thread: invalid operands of types ...

  1. #1
    Join Date
    Mar 2008
    Posts
    2

    invalid operands of types ...

    So I keep getting this error when I compile the code ...

    double deviation(double f[], int size);

    double deviation(double f[], int size){
    double ave = average (f, size);
    double sum = 0.0;
    double ave2 = (ave-f); *************

    for(int i=0; i < size; i++){
    sum +=(ave2 * ave2);
    }
    return sqrt (sum/size);


    invalid operands of types `double' and `double*' to binary `operator-'
    on line 6.

    I've fooled around with it and I just can't figure it out.
    If anyone could point me in the right direction, that'd be great.
    Last edited by AdamDrover; 03-12-2008 at 02:49 PM.

  2. #2
    Join Date
    Mar 2008
    Posts
    2
    Nevermind.
    I'm an idiot

  3. #3
    Join Date
    Dec 2003
    Posts
    3,366
    happens to everyone, if *you* type it then *you* will read what you meant, and everyone else will read what is actually there. A second pair of eyes is one of the fastest ways to find a bug.

  4. #4
    Join Date
    May 2007
    Posts
    843
    What is the error from this program ?

  5. #5
    Join Date
    Dec 2003
    Posts
    3,366
    double ave2 = (ave-f);
    f is a pointer, not a value.

  6. #6
    Join Date
    May 2007
    Posts
    843
    This is the correct statement.

    double ave2 = (ave - *f);
    I hope help others.

    Thnaks jonnin for explanation

Similar Threads

  1. Thoughts on Data Types
    By marsigme in forum C++
    Replies: 5
    Last Post: 09-23-2007, 05:02 PM
  2. Replies: 0
    Last Post: 05-18-2005, 10:40 AM
  3. Flaw in C# ?
    By Gunnar Skogsholm in forum .NET
    Replies: 20
    Last Post: 01-17-2001, 07:43 PM
  4. What is the UDT?
    By Tahui in forum VB Classic
    Replies: 2
    Last Post: 11-22-2000, 11:24 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center