Populate struct values with function argument
- by adohertyd
I am working on a program and part of it requires me to create a struct called DETAILS with the fields name, age, and height. I want to populate the record with data using a function argument. When I run my code I get compiler errors. I have put the errors in comment form beside the lines it is returned for but I can't fix them. Really could do with some help here guys thanks so much.
Here is my code:
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
const int LEN=100;
struct DETAILS
{
char name[LEN];
int age;
double height;
};
person fillperson(struct DETAILS, char[LEN], int, double);
int main()
{
struct person David;
fillperson(David, "David Greene", 38, 180.0); //deprecated conversion from string constant to char * [-Wwrite-Strings]
}
person fillperson(struct DETAILS, char[LEN] name, int age, double height) //expected , or ... before 'name'
{
cin>>David.name>>name;
cin>>David.age>>age;
cin>>David.height>>height;
cout<<"Done"<<endl;
}