I've applied all the solutions provided by you for similar problems but I'm still getting this error:
undefined reference to `setgolf(golf&, char*, int)'
collect2: error: ld returned 1 exit status
here is the code header
#ifndef SANS_H_INCLUDED
#define SANS_H_INCLUDED
const int len = 40;
struct golf
{
char fullname[len];
int handicap;
};
//void setgolf(golf &,char * ,int);
int setgolf(golf &);
void sethandicap(golf &,int );
void showgolf(const golf &);
#endif
here is the file containing the functions definitions
#include <iostream>
#include <cstring>
#include "chapter9exe3.h"
void setgolf(golf & s,char *c ,int hc)
{
strcpy(s.fullname,c);
s.handicap=hc;
}
int setgolf(golf & s)
{
std::cin.getline(s.fullname,len);
if(s.fullname[0] == '\0'&& s.fullname[1] == '\0' && s.fullname[2] == '\0')
return 0;
else
return 1;
}
void sethandicap(golf & s,int n )
{
s.handicap = n;
}
void showgolf(const golf & s)
{
std::cout<<"the full name :"<<s.fullname<<std::endl;
std::cout<<"the handcape :"<<s.handicap<<std::endl;
}
here is the file containing the main function
#include <iostream>
#include "sans.h"
int main()
{
golf player;
char name[len] = "santers God's men";
int handicap = 84;
setgolf(player,name,handicap);
return 0;
}