Thread: reference parameters

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    19

    reference parameters

    Due to the lack of reference parameters being available in C, i need to use pointers to change a value with a function, but I can't seem to figure out how I can pass an array to a function and change the array values, is there a thread somewhere which covers this? or can someone give me an example? thnx

    EDIT: I believe I figured it out, someone correct me if I'm wrong plz

    example:
    Code:
    #define elements 4
    
    int somearray[elements];
    
    void arraychanging(int* array[],int elements)
    {
    int counter = 0;
    
      for(counter = 0;counter<elements;counter++){
        *array[counter] = 1
      }
    }
    
    arraychanging(&somearray,elements);
    Last edited by LowLife; 01-25-2006 at 09:02 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM