Thread: Help with arrays and pointers please...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Quote Originally Posted by crazyeyesz28
    Suppose you have a main() with three local arrays, all the same and type (say float). The first two are already initialized to values. Write a function called “addarrays()” that accepts the address of the three arrays as arguments
    To get you started the prototype of such a function would be like this:
    Code:
    addarrays(float *array1ptr, float *array2ptr, float *array3ptr, unsigned int Size);
    adds the contents of the first two arrays together, element by element; and places the results in the third array before returning.
    something like this
    Code:
    while(size!=0)
    {
       *array3ptr= *array1ptr+*array2ptr;
       array1ptr++;
       array2ptr++;
       array3ptr++;
      Size--;
    }
    Last edited by Quantum1024; 03-17-2005 at 01:43 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointers & arrays and realloc!
    By zesty in forum C Programming
    Replies: 14
    Last Post: 01-19-2008, 04:24 PM
  2. Pointers and multi dimensional arrays
    By andrea72 in forum C++ Programming
    Replies: 5
    Last Post: 01-23-2007, 04:49 PM
  3. Passing pointers to arrays of char arrays
    By bobthebullet990 in forum C Programming
    Replies: 5
    Last Post: 03-31-2006, 05:31 AM
  4. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 09:32 AM
  5. Help understanding arrays and pointers
    By James00 in forum C Programming
    Replies: 2
    Last Post: 05-27-2003, 01:41 AM