Thread: Syntax error !

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    25

    Syntax error !

    Hi,
    This code is supposed to calculate the dot product of two 3-dimensional vectors.
    I get syntax error in line 29. (syntax error before ']' token)
    Code:
    #include<stdio.h>
    #include<stdbool.h>
    #include<stdlib.h>
    
    /* UTILITIES */
    
    #define MAX 3
    float dot_prod(float v1[], float v2[]);
    
    /* MAIN */
    
    int main()
    {
      int i;
      float v1[MAX],
        v2[MAX],
        result;
       
      printf("Enter the first vector\n");
      for (i=0; i<MAX ; i++){
        printf(":");
        scanf("%f",&v1[i]);
      }
      printf("Enter the second vector\n");
      for (i=0; i<MAX ; i++){
        printf(":");
        scanf("%f",&v2[i]);
      }
      result=dot_prod(v1[], v2[]);   /* Line 29 */
      
      printf("%f",result);
      
       return 0;
    }
    
    /* DEFINITION */
    
    float dot_prod(float v1[], float v2[]){
      int i;
      float  a,
             b,
           tot,
       total=0;
      for(i=0;i<MAX;i++){
        a=v1[i];
        b=v2[i];
        tot=a*b;
        total=total + tot;
      }
        return total;
      }

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    Code:
    result=dot_prod(v1, v2);   /* Line 29 */
    Just enter the names if the variables you want to pass, nothing else.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Nov 2007
    Posts
    25

    Smile

    Quote Originally Posted by Elysia View Post
    Code:
    result=dot_prod(v1, v2);   /* Line 29 */
    Just enter the names if the variables you want to pass, nothing else.

    Thanks =)

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