My assignment is to make a program that uses fstream functions to gather integers from one file, isolate the significant digits from each integer, cast them as characters, and output them to another file ( we haven't gotten around to arrays yet and aren't allowed to use them.) This is what I have so far, and though it compiles, the program doesn't end. I think I'm stuck in a loop somewhere and I'm not sure how or where. Help me out, please?
/*
Name: inputBothFileNames
Process: prompt user for input and output file names,
acquire, pass back to calling function
Function Input/Parameters: none
Function Output/Parameters: two file names (string)
Function Output/Return: none
Device Input: keyboard
Device Output: monitor
Dependencies: iostream
*/
void inputBothFileNames ( string &inFileName, string &outFileName );
/*
Name: processData
Process: acquire integer data from one file, decode it,
and output as text in another file
Function Input/Parameters: two file names (string)
Function Output/Parameters: none
Function Output/Return: none
Device Input: harddrive, integer data
Device Output: harddrive, text data
Dependencies: fstream, getNextEvenValue
*/
/*
Name: showErrorMessage
Process: displays error message to user, showing
that input file name does not work
Function Input/Parameters: input file name (string)
Function Output/Parameters: none
Function Output/Return: none
Device Input: none
Device Output: monitor, error message
Dependencies: iostream
*/
void showErrorMessage ( const string &inFileName);
/*
Name: testValidFile
Process: open one file, test for access,
return results
Function Input/Parameters: input file name (string)
Function Output/Parameters: none
Function Output/Return: boolean result of test
Device Input: none
Device Output: hard drive, open file attempt
Dependencies: iostream
*/
bool testValidFile ( const string &fileName);
/*
Name: getNextEvenValue
Process: acquires individual value from file,
if even, acquires, if odd and file still
acessible, continues to acquire
Function Input/Parameters: input stream (ifstream & )
Function Output/Parameters: none
Function Output/Return: next even value (int)
Device Input: hard drive, data acquisition
Device Output: none
Dependencies: fstream
*/
int getNextEvenValue ( ifstream &inf);
/*
Name: convertNumTOChar
Process: decodes large integer to ASCII value,
returns integer as character
Function Input/Parameters: encoded integer
Function Output/Parameters: none
Function Output/Return: decoded character
Device Input: none
Device Output: none
Dependencies: none
*/
char convertNumToChar ( int encodedVal );
// Main Function
int main()
{
// initialize program/function
string inFileName, outFileName;
// acquire first even value
// function: getNextEvenValue
nextEvenVal = getNextEvenValue ( fin );
// loop across input file
// function: fstream .good
while ( fin.good())
{
// convert number to character
// function: convertNumToChar
outputCharacter = convertNumToChar ( nextEvenVal );
// output character to output file
// function: fstream <<
fout << outputCharacter << SPACE;
// check character for space
if ( outputCharacter == SPACE)
{
// increment space counter
spaceCounter ++;
}
// check for tenth space or end of line character
if ( spaceCounter == 10 || outputCharacter == END_OF_LINE )
{
// output end line
// function: fstream <<
fout << endl;
// reset space counter
spaceCounter = 0;
// get next even value
// function: getNextEvenValue
nextEvenVal = getNextEvenValue ( fin );
}
// end loop
}
// output end line
// function: fstream <<
fout << endl;
// close both files
// function: fstream .close
fin.close();
fout.close();