-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstructs3.c
More file actions
42 lines (34 loc) · 898 Bytes
/
structs3.c
File metadata and controls
42 lines (34 loc) · 898 Bytes
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
/* File: structs3.c
*
* Purpose: Illustrate second solution to problem of passing struct
* args -- using typedef
* Input: None
* Output: struct member values
*
* Compile: gcc -g -Wall -o structs3 structs3.c
* Usage: ./structs3
*/
#include <stdio.h>
typedef struct {
double value;
int row;
int col;
} element_t;
void pass_struct(element_t x);
int main(void) {
element_t element;
element.value = 5.5;
element.row = 6;
element.col = 10;
printf("element.value = %f\n", element.value);
printf("element.row = %d\n", element.row);
printf("element.col = %d\n", element.col);
pass_struct(element);
return 0;
} /* main */
void pass_struct(element_t x) {
printf("\nIn pass_struct\n");
printf("x.value = %f\n", x.value);
printf("x.row = %d\n", x.row);
printf("x.col = %d\n", x.col);
} /* pass_struct */