Thread: Syntax Error

  1. #1
    Registered User lord's Avatar
    Join Date
    Dec 2006
    Posts
    61

    Syntax Error

    I have been searching for awhile but I unable to see the syntax error. I feel like I am blind.

    Code:
    double max_arr(const double ar[], int n)
    {
            int i;
            double max = ar[0];
    
    
            if(i = 0; i < n; i++)
              if(max < ar[i])
                max = ar[i];
    
            return max;
    }
    I am getting a syntax error at the start of the if statement.
    Thanks for helping.

  2. #2
    Registered User simguy's Avatar
    Join Date
    Jan 2007
    Location
    Dallas-Ft Worth, TX
    Posts
    10
    your 'if' statement has the construct of a 'for' statement

  3. #3
    Registered User lord's Avatar
    Join Date
    Dec 2006
    Posts
    61
    Silly mistake. Thanks for the quick find.

  4. #4
    Registered User simguy's Avatar
    Join Date
    Jan 2007
    Location
    Dallas-Ft Worth, TX
    Posts
    10
    Don't mention it --- we've all made mistakes that we can't see for the life of us. It's always good to have someone around that sees the trees in the forest in a different way.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 04:09 AM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. ras.h errors
    By Trent_Easton in forum Windows Programming
    Replies: 8
    Last Post: 07-15-2005, 10:52 PM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM