Thread: Parsing and returning array pointers?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2009
    Posts
    33

    Help needed with pointing to arrays.

    I'm trying to write a function that takes as input 3 arrays, does some calculations, puts some values into a global array, then returns a pointer to that array.

    function is:

    Code:
    GLfloat calcNormal(GLfloat* B1, GLfloat* B2, GLfloat* T)
    {
        //calculations here.
        return normArray[0];
    }
    If I define 3 arrays, A(0,0,0), B(1,0,0), and C(0,1,0), then call printf("%f\n", calcNormal(A[0], B[0], C[0])[2]), compiler says arguments are of wrong type. If I try passing &A[0], &B[0] and &CP[0], compiler says subscripted value is neither array nor pointer.

    How should I be passing array pointers to the function?
    Last edited by thealmightyone; 03-26-2009 at 08:25 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Coverting array to string
    By do_kev in forum C Programming
    Replies: 5
    Last Post: 03-13-2008, 03:15 PM
  2. Struct/parse returning wrong information
    By dontknowc in forum C Programming
    Replies: 5
    Last Post: 12-04-2007, 01:39 PM
  3. Returning an Array of Pointers to Objects
    By randomalias in forum C++ Programming
    Replies: 4
    Last Post: 04-29-2006, 02:45 PM