Want to copy/store data from struct into individual arrays

I wrote a basic get function that takes the elements of a struct, and copies/stores them into separate variables. I want to do the same thing, except to store an array of structs into array variables (the key thing is that I want to use the get function that I already wrote).

I'm getting a bunch of errors, and one of them is that there isn't a matching function call in the embedded function (line 29) that I put inside my second function (I thought that I matched up the variables correctly with my first get function (i.e. n, c, a, and x)).

Thanks for the help.

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <iostream> 
#include <cstdlib> 

using namespace std; 

struct ABC{ 

int n; 
char c; 
double a[3]; 
}; 


void get( int & n, char & c, double a[3], const ABC & x ){ 

n = x.n; 
c = x.c; 

for (int i = 0; i < 3; i++){ 
a[i] = x.a[i]; 

} 
} 

void get( int n[], char c[], double a[][3], const ABC x[], int elements ){ 

for (int i = 0; i < elements; i++){ 

get(n, c, a, x); 

} 

} 

int main(){ 

ABC x = {number, m, {1, 2, 3}}; 

ABC xx[4] = { 

{123, 'A', {1.1, 1.2, 1.3}}, 
{234, 'B', {2.1, 2.2, 2.3}}, 
{345, 'C', {3.1, 3.2, 3.3}}, 
{456, 'D', {4.1, 4.2, 4.3}} 

}; 

int n; 
char c; 
int a[] = {}; 

int n1 [4] = {}; 
char c1 [4] = {}; 
double a3 [4] [3] = {}; 

int elements = 3; 

get( n, c, a, x ); 
get(n1, c1, a3, xx, elements); 

return 0; 
} 
Last edited on
Also, I should note that on line 58, that is just to test the first get function.
Topic archived. No new replies allowed.