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

typedef struct _Point {
    int x;
    int y;
} Point;
void print_point(Point p) {
    printf("{.x = %d,  .y = %d}\n", p.x, p.y);
}
int main(int argc, char* argv[]) {
    //int array[] = {1, 2, 3};
    
    Point* points = malloc(sizeof(*points) * 3);
            
    points[0].x = 5;
    points[0].y = 6;
    points[1].x = 15;
    points[1].y = 16;
    points[2].x = 25;
    points[2].y = 26;

    print_point( points[2] );
    points[2].x *= 10;  // same as points[2].x = points[2].x * 10
    points[2].y *= 10;  // same as points[2].y = points[2].y * 10
    print_point( points[2] );

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

//      { .x =  5, .y =  6 },
//      { .x = 15, .y = 16 },
//      { .x = 25, .y = 26 }
//  };

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