forked from mmorri22/GreatIdeas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray4.cpp
43 lines (33 loc) · 939 Bytes
/
array4.cpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <cstdlib>
/********************************************
* Function Name : main
* Pre-conditions : void
* Post-conditions: int
*
* This is the main driver function for the program
********************************************/
int main(void){
long unsigned int numCharacters = 13;
char* hello = (char *)malloc( numCharacters * sizeof(char) );
char* reference = hello;
hello[0] = 'H';
hello[1] = 'e';
hello[2] = 'l';
hello[3] = 'l';
hello[4] = 'o';
hello[5] = ',';
hello[6] = ' ';
hello[7] = 'W';
hello[8] = 'o';
hello[9] = 'r';
hello[10] = 'l';
hello[11] = 'd';
hello[12] = '\n';
for(long unsigned int iter = 0; iter < numCharacters; iter++){
std::cout << (void *)reference << " " << *(reference) << " " << (void *)(hello + iter) << " " << hello[iter] << std::endl;
reference = reference + 1;
}
delete hello;
return 0;
}