Having trouble with this line of code: g.fullname = name; in golf.cpp
Error 1 error C2440: '=' : cannot convert from 'const char *' to 'char [40]'
2 IntelliSense: expression must be a modifiable lvalue
// golf.h -- for pe-9.cpp
constint Len = 40;
struct golf
{
char fullname[Len];
int handicap;
};
//non-interactive version:
// function sets golf structure to provided name, handicap
// using vlues passed as arguments to the function
void setgolf(golf & g, constchar * name, int hc);
// interactive version:
// function name and handicap from user
// and sets the members of g to the values entered
// returns 1 if name is entered, 0 if name is empty string
int setgolf(golf & g);
// function resets handicap to new value
void handicap(golf & g, int hc);
// function displays contents of golf structure
void showgolf(const golf & g);
// golf.cpp load golf struc
#include<iostream>
#include "golf.h"
void setgolf(golf & g, constchar * name, int hc)
{
g.fullname = name;
g.handicap = hc;
// strlen(name)
}
// chapEx9-1.cpp
#include <iostream>
#include "golf.h"
usingnamespace std;
int main()
{
golf ann;
setgolf(ann, "Ann Birdfree", 24);
}