forked from malmhaug/C_AbsBegin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathC9E2CarStructArray.c
43 lines (28 loc) · 880 Bytes
/
C9E2CarStructArray.c
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
/* Challanges Ch9E2 - CarStructArray */
// By Jim-Kristian Malmhaug | Date: 24 July 2014
//Notes:
//References:
#include <stdio.h>
#include <string.h>
//Making the car struct.
typedef struct car {
char make[20];
char model[20];
int year;
int miles;
} cars;
int main() {
cars myCars[3] = {{"Subaru","Impreza",1998,120000},
{"Ford","Escort",1987,295000},
{"Mazda","626",1997,179000}};
int x = 0;
for (x = 0 ; x < 3 ; x++){
printf("\nThe Car is a:\n");
printf("\nMake: %s", myCars[x].make);
printf("\nModel: %s", myCars[x].model);
printf("\nYear: %d", myCars[x].year);
printf("\nMiles: %d", myCars[x].miles);
printf("\n-----------------\n");
}
return (0);
}