Good day yet again ladies and gents. Today I'm having problems with strings and such. I've been tasked with creating fixed char arrays to contain first name, last name, and middle name. I've managed that, and have the calls in my main. I'm also tasked with using strlen (specifically) to find the length of the strings to create a dynamic array to hold all three names. This is where I'm running into problems. the first cpp file I'll post has the original functions for entering the names into the strings. The commented out portion was where I was getting the link individually (which works), but I am trying to write a separate function in another cpp file which keeps giving me linking errors. I'm not sure where they are coming from since I already used the extern keyword in the header. I'm sure it's possible to write a separate function in a separate cpp file, but am I making more trouble than it's worth? Here are the files:
Header
#ifndef NAMEINP_H
#define NAMEINP_H
const int maxin = 16;
extern char lastName[maxin];
extern char firstName[maxin];
extern char midName[maxin];
char getlast( char lastName[] , int maxin);
char getfirst( char firstName[] , int maxin);
char getmid( char midName[] , int maxin);
//void displayName (char * name);
#endif
Here are the functions
#include "nameinp.h"
#include <iostream>
#include <string.h>
using namespace std;
//Input last name
char getlast( char lastName[] , int maxin)
{
cout << " Please enter your last name up to 15 characters " << endl;
cin.getline(lastName, maxin, '\n' );
//size_t lastLen;
//lastLen = strlen(lastName);
//cout << lastLen << endl;
return 0;
}
//Input first name
char getfirst( char firstName[] , int maxin)
{
cout << " Please enter your first name up to 15 characters " << endl;
cin.getline(firstName, maxin, '\n' );
//size_t firstLen;
//firstLen = strlen(firstName);
//cout << firstLen << endl;
return 0;
}
//Input middle name
char getmid( char midName[] , int maxin)
{
cout << " Please enter your middle name up to 15 characters " << endl;
cin.getline(midName, maxin, '\n' );
//size_t midLen;
//midLen = strlen(midName);
//cout << midLen << endl;
return 0;
}
Here is the function I'm trying to write that's giving me the hassles
#include "nameinp.h"
#include <iostream>
#include <string.h>
using namespace std;
//Calculate the String Lengths
size_t totallength (size_t)
{
size_t fullength = 0;
size_t lastLen;
lastLen = strlen(lastName);
cout << lastLen << endl;
size_t firstLen;
firstLen = strlen(firstName);
cout << firstLen << endl;
size_t midLen;
midLen = strlen(midName);
cout << midLen << endl;
fullength = lastLen + firstLen + midLen;
return 0;
}
Okay, what am I screwing up? Thank you