Passing Arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DCarrie
    New Member
    • Oct 2007
    • 1

    #1

    Passing Arrays

    Im making a program for C computer class which deals with algebra. I need a way to pass Arrays to different functions for things like Addition, Vector multiplication etc. Can anyone show me the proper syntax? The following are my prototype and function header (I think its called header, it goes at the top of my program).

    Code:
    int addition = (int matrix1, int matrix2); 
    int addition (matrix1, matrix2);
    Thank you for any help,
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    The second line there looks correct - it's called the prototype. I actually call it the function declaration (not sure if that's technically correct). But the first line you have makes no sense - the syntax you use says you are declaring an int variable and initializing it to (matrix1, matrix2) - which just won't compile.

    Comment

    • mattmao
      New Member
      • Aug 2007
      • 121

      #3
      It is called prototype.

      You can google for better clarification.

      So far as I know when you want to use the prototype, use it as:

      int add(int array1[], int array2[]);

      or

      int add(int *array1, int *array2);




      I assumed that you are talking about arrays in the method parameter.

      Comment

      Working...