ChurchedAtheist
Your resident psycho hobo
Im trying to create a program that converts unix/windows txt files. I think the issue is in my enums. any ideas?
[HIGHLIGHT=c++]enum FileType { WINDOWS, UNIX };
// Include Files //////////////////////////////////////////////////////////////
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
#include <fstream.h>
// Function Prototypes ////////////////////////////////////////////////////////
// Program Mainline ///////////////////////////////////////////////////////////
int main( )
{
char infile[256];
char outfile[256];
char ch;
ofstream output;
ifstream input;
cout << "Enter the name of the source file: ";
cin.getline( infile, sizeof( infile ) );
cout << endl;
ifstream fin( infile, ios::binary );
if ( !fin ) {
cerr << "File " << infile << " not found!" << endl;
cout << "Press any key to close the program" << endl;
getch();
return 2;
}//endif
cout << "Enter the name of the destination file: " << endl;
cin.getline( outfile, sizeof( outfile ) );
cout << endl;
input.open (infile, ios::binary);
output.open (outfile, ios::binary);
FileType = UNIX;
while ( fin.get( ch ) ) {
if ( ch == '\r' ) {
FileType = WINDOWS;
}else{
if ( ch == '\n' && FileType == UNIX ) {
output << '\r';
}//endif
output << ch;
}//endif
}//endwh
getch();
return 0;
}//endmn
[/HIGHLIGHT]
[HIGHLIGHT=c++]enum FileType { WINDOWS, UNIX };
// Include Files //////////////////////////////////////////////////////////////
#include <iostream.h>
#include <iomanip.h>
#include <conio.h>
#include <fstream.h>
// Function Prototypes ////////////////////////////////////////////////////////
// Program Mainline ///////////////////////////////////////////////////////////
int main( )
{
char infile[256];
char outfile[256];
char ch;
ofstream output;
ifstream input;
cout << "Enter the name of the source file: ";
cin.getline( infile, sizeof( infile ) );
cout << endl;
ifstream fin( infile, ios::binary );
if ( !fin ) {
cerr << "File " << infile << " not found!" << endl;
cout << "Press any key to close the program" << endl;
getch();
return 2;
}//endif
cout << "Enter the name of the destination file: " << endl;
cin.getline( outfile, sizeof( outfile ) );
cout << endl;
input.open (infile, ios::binary);
output.open (outfile, ios::binary);
FileType = UNIX;
while ( fin.get( ch ) ) {
if ( ch == '\r' ) {
FileType = WINDOWS;
}else{
if ( ch == '\n' && FileType == UNIX ) {
output << '\r';
}//endif
output << ch;
}//endif
}//endwh
getch();
return 0;
}//endmn
[/HIGHLIGHT]