For this one problem on my homework assignment, it says to initialize the pointer ptr and make it point to the first element of the array. Here is what I have written:
When I run this, the output gives me "abFHXY" and then some lines and symbols. Is this correct? If not then what am I doing wrong?
#include "stdafx.h"
#include <iostream>
#include <cstdlib>
using namespace std;
int_tmain(int argc, _TCHAR* argv[])
{
char array[6] = {'a','b','F','H','X','Y'};
char *ptr;
ptr = &array[0];
cout << ptr << endl;
system("PAUSE");
return 0;
}
When I run this, the output gives me "abFHXY" and then some lines and symbols. Is this correct? If not then what am I doing wrong?