Copying Arrays using Pointers

I need to write a program that stores the following #'s in the array miles: 15,22,16,18,27,23,20. Need to copy that to array named dist. then display dist values. using pointer notation. Dont know how to set it up...
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
int main()
{
const int VALUES = 7;
int mPtr;
int i, miles[VALUES] = {15,22,16,18,27,23,20};
mPts = &miles[0];
...... //not sure what to do


Can anyone help?
Thanks
Let assume that the size of your source array (and destination array ) is SIZE. Then you can write

for ( int *p = source, *q = dest; p != source + SIZE; ++p, ++q ) *q = *p;
Having trouble putting this into code format!
1
2
3
4
5
6
7
8
9
#include <iostream>
using namepsace std;
int main()
{
const int SIZE = 7;

int *p = &miles;
int *q = &distance
for ( 




SORRY?!?!?!?!
Last edited on
You even can not simply rewrite what I showed you. Where did you find in my example the following int *p = &miles;?!!!
Sorry I am having trouble understand pointers and arrays!
Topic archived. No new replies allowed.