Code:
data.cpp: In function `int WriteDatabase()':
data.cpp:58: `PersonInfo' undeclared (first use this function)
data.cpp:58: (Each undeclared identifier is reported only once
data.cpp:58: for each function it appears in.)
Those are the errors I am getting from this:
Code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int FillDatabase ( void );
int WriteDatabase ( );
struct Database
{
string FirstName, LastName;
int Age;
string Marital;
string Occupation;
};
int main ( void )
{
FillDatabase();
WriteDatabase();
return 0;
}
int FillDatabase ( void )
{
Database Person;
Database * PersonInfo;
PersonInfo = &Person;
cout<< "Name: ";
cin>> Person.FirstName >> Person.LastName;
cout<< "Age: ";
cin>> Person.Age;
cout<< "Marital Status: ";
cin>> Person.Marital;
cout<< "Occupation: ";
cin>> Person.Occupation;
return 0;
}
int WriteDatabase ( )
{
fstream Log;
Log.open("Data.txt", ios::app);
if (Log == NULL)
{
cout <<"Open Error" <<endl;
return 1;
}
Log <<"Name:" <<endl
<<PersonInfo->FirstName <<" " <<PersonInfo->LastName <<endl
<<"Age:" <<endl
<<PersonInfo->Age <<endl
<<"Marital Status:" <<endl
<<PersonInfo->Marital <<endl
<<"Occupation:" <<endl
<<PersonInfo->Occupation <<endl <<endl;
Log.close();
return 0;
}
What am I missing?
I am trying to modularize this thing as much as possible, and while it's still in the stage of taking shape, I can't seem to figure out how to write the data from the structure in it's own function.