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
#include <stdio.h>
#include <stdlib.h>

// This is from Section 3 (4:30pm).  A similar exercise was done in Section 2.

int main(int argc, char* argv[]) {
    
    char  s[] = "arg";
    char* t  = "fri";
    char* t_1 = &t[1];
    t_1[-1]
    int   n  = 5;
    int*  a  = &n;

// For each expression write
//    expression     |      type     |    expression in words
// ------------------+---------------+------------------------------
//  0.  a            | int*          |  "a" or "the address a"
//  1.  n            | int           |  "n"  (or "the value n")
//  2.  &n           | int*          |  "address of n"
//  3.  s[0]         | char          |  "the first element of s"
//  4.  &(s[0])      | char*         |  "address of the first element of s
//  5.  *a           | int           |  "value at a"
//  6.  *(&(n))      | int           |  "the value n"
//  7.  *(&(a))      | int*          |  "the address a" (== &n)
//  8.  t[0]         | char          |  "the first element of t"
//                   |               |  "address at "
//  9.  t[-1]        | char          |
// 10.  &t[a[n * 0]] | char*         |  "address of the sixth element of t"
// 11.  &(t[0])      | char*         |  "address of the first element of t"
//                   |               |  (== t)
// 12.  &t           | char**        |  "address of the address of the
//                   |               |   first element of t"
//                   |               |  "address of the address t"
//
// Don't worry if it will run properly.  Just analyze the type.


    return EXIT_SUCCESS;
}
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */

© Copyright 2019 Alexander J. Quinn         This content is protected and may not be shared, uploaded, or distributed.