Files
  • main.cpp
main.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
44
// Include the standard (STD) 
//  input and output (IO) header
#include <stdio.h>

// Main function
// Returns: Integer
int main() {
  
  // Create an Integer
  int numberValue = 5;
  // Show the address of the pointer
  printf("The address of the variable is %p. \n", &numberValue);

  // Store the value of an Integer address
  int *numberValuePointer = &numberValue;
  
  // Show the address of the pointer
  printf("The address of the variable is %p. \n", numberValuePointer);

  // Create a struct (structure)
  // Using struct allows for defining new
  //  types of data.
  struct Node 
  { 
    int data; 
    struct Node *next; 
  };

  // Create a new variable of type 'Node'
  Node demo;
  // Change its internal 'data'
  demo.data = 5;
  // Create a new variable of type 'Node'
  demo.next = new Node;
  // Change the new variable's 'data'
  demo.next->data = 6;

  printf("The value of the first 'demo' is %i, \nand the value of the second is %i.\n", demo.data, demo.next->data);

  // Return 0
  return 0;

}
gcc version 4.6.3