-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstructArrEx.cpp
41 lines (33 loc) · 875 Bytes
/
structArrEx.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
//This example shows to declare arrays of simple structs in C++.
#include <iostream>
using namespace std;
struct point3D{
float xCrd;
float yCrd;
float zCrd;
} pointsIn3d[3];
int wrtContentsPt(point3D point1);
int main(void){
int res, i;
//set data of four points in the array
pointsIn3d[0].xCrd = 3.5;
pointsIn3d[0].yCrd = 2.0;
pointsIn3d[0].zCrd = 1.0;
pointsIn3d[1].xCrd = 4.5;
pointsIn3d[1].yCrd = 2.0;
pointsIn3d[1].zCrd = 1.0;
pointsIn3d[2].xCrd = 5.5;
pointsIn3d[2].yCrd = 2.0;
pointsIn3d[2].zCrd = 1.0;
for(i=0; i<3; i++){
res = wrtContentsPt(pointsIn3d[i]);
}
return 0;
}
int wrtContentsPt(point3D point1){
cout << "Coordinates of the point" << "\n";
cout << point1.xCrd << "\n";
cout << point1.yCrd << "\n";
cout << point1.zCrd << "\n";
return 0;
}