Mac Osxtopus
Registered
Ok, due to the board, i will not supply alligators to anything in this post, since it will not show anyways.
#include iostream
void cube(int *n, int num); /* the pointer, and num's 1st array element passed to this function*/
main()
{
int i, nums[10]; /* i is for the numbers, *n is the pointer to num, which stores i that increases all the way to 10 */
for(i=0; i<10; i++) nums = i+1;//#'s 1-10
cout "Original Contents: ";
for(i=0; i<10; i++) cout nums ' ' ;//display
cout << '\n';
cube(nums, 10); // compute cubes
cout << "altered contents: ";
for(i=0; i<10; i++) cout nums ' ';/* display the cubed values of 1-10*/
return 0;
}
void cube(int *n, int num)
{
while(num) {
*n = *n * *n * *n;/* ??? I know this cubes....but where does the pointer point? it was never declared*/
num--;/* ??? what are these for? they just cancel out anyways*/
n++;
}
}
#include iostream
void cube(int *n, int num); /* the pointer, and num's 1st array element passed to this function*/
main()
{
int i, nums[10]; /* i is for the numbers, *n is the pointer to num, which stores i that increases all the way to 10 */
for(i=0; i<10; i++) nums = i+1;//#'s 1-10
cout "Original Contents: ";
for(i=0; i<10; i++) cout nums ' ' ;//display
cout << '\n';
cube(nums, 10); // compute cubes
cout << "altered contents: ";
for(i=0; i<10; i++) cout nums ' ';/* display the cubed values of 1-10*/
return 0;
}
void cube(int *n, int num)
{
while(num) {
*n = *n * *n * *n;/* ??? I know this cubes....but where does the pointer point? it was never declared*/
num--;/* ??? what are these for? they just cancel out anyways*/
n++;
}
}