hi everyone, can someone tells me whats wrong with this piece of code. i cant figured it out. i get an error: lastname was not declared in this scope in structure.h (in function: newEntry @ line } while (!checkString(lastname, 1));
i will be grateful if someone can help.
here is the part of my structure.h
Code:
#include <iomanip>
struct contact
{
char lastname[15];
char initial[2];
char firstname[15];
char street[20];
char city[15];
char state[15];
char country[20];
char telephone[15];
char email[20];
contact *next;
};
void newEntry()
{
contact *root; //This will not changeor we lose the list in memory
contact *conductor; //This will point to each node as it moves downthe list
root = new contact; //Sets the root to point to something actually
root -> next = 0; //Otherwise it will not work well
char continueNewEntry = 'Y';
do
{
clearScreen();
showTitle();
centerString("NEW Contact");
centerString("--------------------------");
do
{
cout << "Last Name: ";
cin >> root -> lastname;
} while (!checkString(lastname, 1));
do
{
cout << "Initial: ";
cin >> root -> initial;
} while (!checkString(initial, 2));
here is part of my validation.h
Code:
bool checkString(char* str, int n)
{
unsigned int i;
if (n == 1)
{
if (strlen(str) == 0 || strlen(str) > 15)
{
cout << "Field is limited to 15 characters & must not be empty!";
return false;
}
else
return true;
}
if (n == 2)
{
if (strlen(str) > 2)
{
cout << "Field is limited to 2 characters!";
return false;
}
else
return true;
}
Here is my header file for main.cpp
#include <iostream>
#include <string.h>
#include <fstream>
#include "ui.h"
#include "structure.h"
#include "validation.h"
Thank you in advance friends