Hello GabriellaN3,
In addition to what
KittyIchigo1 said I have found this link to be of more help
http://www.cplusplus.com/articles/z13hAqkS/
Looking at your pseudo code:
// start. I.E., " int main()".
// Declarations
// InputFile geraldineFile
// Check that it opened. Unless it means to define the file stream only.
// InputFile geraldFile
// Check that it opened. Unless it means to define the file stream only.
// OutputFile mergedFile
// num geraldineNum
// num geraldineArea
// string geraldineLastName
// string geraldineAddress
// num geraldNum
// num geraldArea
// string geraldLastName
// string geraldAddress
// string areBothAtEnd= "N"
// num END_NUM = 999
// getReady()
// while areBothAtEnd <> "Y"
// mergeRecords()
// endwhile
// finishUp()
// stop. Closing } of "main".
|
I do not get the impression that these variables should be global variables. It looks to me like they should be defined in "main" and passed to the functions that need them. Or defined in the functions that need them.
You should try to avoid using global variables. Those variables that start with "constexpr" or "const" are OK because they can not be changed.
Just looking at the code I see some problems.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
void getReady()
{
geraldineFile.open("GeraldinesLandscaping.txt", ios::in);
geraldFile.open("GeraldsLandscaping.txt",i os::in);
mergedFile.open("MergedLandscaping.txt", ios::in);
readGeraldine();
readGerald();
checkEnd();
return; // <--- Not necessary with a "void" function. the function will return at the closing }.
}
|
Lines 3 and 4 are both defined as an "ifstream". The "i" says it is an input stream, so the ", ios::in" is either redundant or has no effect.
Line 5 is a different problem. "mergedFile"was defined as an "ofstream" meaning it is an output stream, so I am not sure if the ", ios::in" will be a problem or just ignored.
In all 3 lines the ", ios::in" is not needed.
Also a few blank lines and some spaces make it much easier to read.
In the function "readGeraldine":
1 2 3 4 5 6 7 8 9 10 11 12 13
|
void readGeraldine()
{
geraldineFile >> geraldineNum;
geraldineFile >> geraldineLastName;
geraldineFile >> geraldineAddress;
geraldineFile >> geraldineArea;
if (!geraldineFile.eof())
{
geraldineNum = END_NUM;
}
return;
}
|
Given this code and not knowing what the input file looks like I would guess that line 3 would be the read that sets the "eof" bit which means that you if statement is in the wrong place. When line 3 sets the "eof" bit it still tries to read 3 more fields. In the end the value of all 4 variables may depend on which set of C++ standards you are using.
The variable "END_NUM" is misleading. Being all capital letters you give the impression that it is defined as a constant, but it is not. It should be defined as a constant for the way it is used.
And again the return statement is not needed.
Your program uses 2 input files it helps to provide those file, or a small portion to work with, so everyone can see what you are using and use the same information.
Andy