|
-
March 24th, 2010, 06:54 PM
#1
Pointers
Hello, writing out some code for a project for college and ran into a rut.
I have an Array of Pointers :
Code:
int * ArrayOfPtrs[3];
ArrayOfPtrs[0] = firstIntPtr;
ArrayOfPtrs[1] = secondIntPtr;
ArrayOfPtrs[2] = sumPtr;
And each of these Pointers point to an int Array that is Dynamically Allocated.
Code:
int * firstIntPtr;
firstIntPtr = new int[sizeOfIntArray];
int * secondIntPtr;
secondIntPtr = new int[sizeOfIntArray];
int * sumPtr;
sumPtr = new int[sizeOfIntArray];
I've passed the Array of Pointers to a function outside of main that is suppose to add the firstIntPtr and secondIntPtr together cell by cell using the paper and pencil algorithm and then putting that in the sumPtr Array.
The problem i ran into is deals with the Array of Pointers, each Pointer in the array points to the address of the first cell of the first, second, and sum arrays. I am having difficultly getting the pointers to point to the last cell and working its way back to the beginning.
Example:
0 0 1 2 3 4
0 1 2 3 4 5
----------------
0 1 3 5 7 9
I've tried it one way, but comes up with errors and isn't correct.
Thanks for any help, suggestions.
I'll continue to keep working on it.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|