Copying arrays using pointers

The output of my code comes out with spaces (T h i s i s a t e s t)
can some please help me with this.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include "stdafx.h"
#include <iostream>

using namespace std;

int main()
{
	const char VALUE = 15;
	char message[] = "This is a test";
	char mess2[] = "";
	int i;
	char *mPt = message;
	char *mmPt = mess2;
	for (i = 0; i < 15; i++)
 {
  *mmPt = *mPt++;
  mmPt++;
 }
	
	for (i = 0; i < VALUE; i++)
	cout << mess2[i] << "  ";
	cout << endl;

system("pause");
return 0;
}
cout << mess2[i] << " ";
Last edited on
I can't believe I didn't catch that. Thank you very much Moschops.
Topic archived. No new replies allowed.