I am working on a struct program and it is working perfectly except for one thing. 2 of my struct elements are arrays and I can't populate them. I have tried a number of different things but I keep getting compiler errors. What is the correct way to pass an array into a struct? Here is my code:

#include <cstdlib>
#include <iostream>

using namespace std;

const int MAXLEN=100;

struct DETAILS
{
 char fname[MAXLEN]; 
 char sname[MAXLEN]; 
 int age;
 double height;
 double weight;
} person, personcpy; //declare structs

//function prototypes
 DETAILS fill(struct DETAILS&, const char fname[], const char sname[], int age, double height, double weight);
 DETAILS copy(struct DETAILS&, struct DETAILS&);
 int print(struct DETAILS);

int main()
{
 fill(person, "Jim", "Davis", 23, 163.3, 83.6);
 copy(person, personcpy);
 print(personcpy);

 return 0;
}

DETAILS fill(struct DETAILS &person, const char fname[], const char sname[], int age, double height, double weight)
{
//assign the function arguments to the struct varibles for 'Person'
 person.fname=fname[];
 person.sname=sname[];
 person.age=age;
 person.height=height;
 person.weight=weight;

 cout<<"Done"<<endl;
 return person;
}

PERSON makecopy(struct DETAILS &person, struct DETAILS &personcpy) 
{
//Copy the 'person' struct items to 'personcpy'
 personcpy.fname=person.fname;
 personcpy.sname=person.sname;
 personcpy.age=person.age;
 personcpy.height=person.height;
 person.weight=person.weight;

 return personcpy;
}

 int printperson(struct PERSON fredcpy)
{
//Should output the copied content to the screen
  cout << "First Name: " <<personcpy.fname<< endl;
  cout << "Surname: " <<personcpy.sname <<endl;
  cout << "Age: " <<personcpy.age << endl;
  cout << "Height: " <<personcpy.height << endl;
  cout << "Weight: " <<personcpy.weight <<endl;

  return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.