Exforsys
+ Reply to Thread
Results 1 to 3 of 3

Different Approaches Needed

This is a discussion on Different Approaches Needed within the C and C++ forums, part of the Programming Talk category; What are the different ways a programmer of C programming language can pass arrays to functions? Kindly provide insight on ...

  1. #1
    Angela is offline Member Array
    Join Date
    Apr 2006
    Answers
    85

    Thumbs up Different Approaches Needed

    What are the different ways a programmer of C programming language can pass arrays to functions? Kindly provide insight on this concept


  2. #2
    caradoc is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    122
    One of the approach is you can pass the array to a function by value. These can done in three ways depending on your needs and usage. It is
    Put the array in a struct.
    Create a copy of the array in the calling function.
    Create a copy of the array in the called function.


  3. #3
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124
    To avoid the approach of calling a function that requires a long list of arguments one can store the variables into an array, then pass a POINTER to the array to the function. The array isn't actually passed to the function but just the array's location in the memory. This is known as PASS BY REFERENCE. The name of an array references the array's location in the memory, its ADDRESS.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...