I'm having a bit of a problem using enum variables. The program below compiles just fine, but the output program at the end is blank. Any hints?

//	Program Reformat reads characters from file DataIn and 
//	writes them to DataOut with the following changes:             
//	all letters are converted to uppercase, digits are
//	unchanged, and all other characters except blanks and         
//	newline markers are removed.                                       

#include <iostream>
#include <cctype>
#include <fstream>
using namespace std;

enum CharType {LO_CASE, UP_CASE, DIGIT, BLANK_NEWLINE, OTHER};

//	Function pPrototype 
	CharType KindOfChar(char);
//	Post: character has been converted to the corresponding            
//	constant in the enumeration type CharType.           

int main ()
{
	// declare all variables
	ifstream dataIn;
	ofstream dataOut;
	char  character;
	  
	// prepare files for reading and writing
	dataIn.open("reformat.dat");
	dataOut.open("dataOut.dat");
    
	// get character 
	dataIn.get(character);    // Priming read
	while (dataIn)
	{
		CharType KindOfChar (char character);
		cout << character;

		switch (KindOfChar(character))
		{       
			case LO_CASE:		character = character - 32;	 
								break;
			case UP_CASE:		break;
			case DIGIT:			break;
			case BLANK_NEWLINE:	break;
			case OTHER:			character = ' ';
								break;
		}
		// print charactedr to file
		cout << character;  
		dataOut << character;
		// read in next character
		dataIn.get(character);
	}
return 0;
}

                                                            
//*************************************************         
                                                            
CharType KindOfChar(char character)     
{
  if (islower(character))	               
    return LO_CASE;
  else if (isupper(character)) 
    return UP_CASE; 
  else if (isdigit(character))
    return DIGIT;
  else if (character == ' ' || character == '\n')
    return  BLANK_NEWLINE;
  else
	  return  OTHER;
}

the output program at the end is blank.

The input file is not opened? You might use .is_open() to check that.

I went back in and explicitly labeled the input and output files with F:\\ etc. That seems to have done the trick! Thanks.

Another problem solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.