|
-
February 25th, 2007, 11:56 PM
#1
[RESOLVED] No File Output?
My girl has been taking a C++ Programming Class @ Baylor in Waco, TX. I've been trying to help her and I can't seem to see why the file does not output. Everything looks like it should check out. Program Runs without any runtime errors. Compiler Gives no errors or warnings at all. But output File is null. I know the variable being output has value due to the display statement to screen. So anybody with an idea plz feel free to speak up. Cheers!
Code:
/******************************************************************************
* File: Cipher.cpp
* Description: Program to encrypt/decrypt a file provided the correct
* keyword is provided.
* Created: 20070225
*****************************************************************************/
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
//Variable Declaration
int MenuChoice,Value;
string FileName1,FileName2;
char Key[6];
char Data,Encrypted;
ifstream InFile;
ofstream OutFile;
while (MenuChoice!=3)
{
//Display main menu
cout << "-=Main Menu=-\n";
cout << "1) Encrypt File\n";
cout << "2) Decrypt File\n";
cout << "3) Quit Program\n";
cin >> MenuChoice;
if(MenuChoice==1)
{
cout << "What is the file you wish to encrypt?\n";
cin >> FileName1;
cout << "Where would you like to save the data?\n";
cin >> FileName2;
InFile.open(FileName1.c_str());
OutFile.open(FileName2.c_str());
if (!InFile)
{
cout << "Sorry, File does not exit!" << endl;
}
else
{
cout << "Please provide a password:\n";
cin >> Key[0]>> Key[1]>> Key[2]>> Key[3]>> Key[4]>> Key[5];
while (InFile >> Data)
{
Value++;
if (Value=6) Value=0;
Encrypted = Data + Key[Value];
cout << Data << " " << Encrypted << "\n";
OutFile << Encrypted;
}
}
}
else if(MenuChoice==2)
{
cout<< "What is the name of the file to decrypt?"<<endl;
cin >> FileName1;
cout<< "where would you like it saved?"<<endl;
cin >> FileName2;
InFile.open(FileName1.c_str());
OutFile.open(FileName2.c_str());
if(!InFile)
{
cout << "Sorry, File does not exit!" << endl;
}
else
{
while(InFile >> Data)
{
Value++;
if(Value==6)Value=0;
Encrypted=Data-Key[Value];
cout << Encrypted << " " << Data << endl;
OutFile << Data;
}
}
}
}
return 0;
}
-
February 26th, 2007, 12:19 AM
#2
Re: No File Output?
Sorry guys, Right after i asked this question we found the issue. The compiler while it showed termination of the program after running it didn't release it from the system. The .exe still showed up under the Task Manager. When all 20 of the duplicate .exe's were removed the program functioned normally.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|