This is my first time on this site and I appreciate any help on my problem. I am in my first C++ class and I admit I am not an expert at computer programing, so if you could make your answers as dumbed down an specific as possible it would help out my beginner status immensely.
I will be creating a program that decodes encrypted text files. The files are comprised of several sets of ten integers. Depending on the file, there are a number of random values in the file prior to the number for each character. For example, in a file there might be three random numbers, than a number representing a character, then three more random numbers, than the next number representing a character, and so on.
The program will needs to prompt the user for the input file, then the output file, and the number of random numbers to skip before each legitimate integer/character. Note that my program needs to be able to handle any number of leading random numbers. Meaning it might have three random numbers before a legitimate one, or thirty random numbers before.
Here is my whole program so far. The function I need to create is called skipVariable, if someone could please help me create this function it would be oh so helpful i have been staring at it for hours and I just can't imagine how to complete this task.
//Header Files
#include <iostream>
#include <fstream>
using namespace std;
// Global Constants
const char SPACE = ' ';
//Function Prototypes
/*
name: programTitle
input: none
output: void (string)
dependencies: none
process: output string
*/
void programTitle();
/*
name: promptUser
input: none
output: void file name and int skip number
dependencies: none
process: output string name and skip number int
*/
void promptUser ( string &IN_FILE_NAME, string &OUT_FILE_NAME, int &SKIP_NUMBER);
/*
name: openInputFile
input: ifstream &inf, &fileName (string)
output: good bad file (bool)
dependencies: none
process: test if file can be opened/ does it exist
*/
bool openInputFile( ifstream &inf, const string &fileName );
/*
name: skipVariable
input: skip number(integer)
output: calculated result (int)
dependencies: none
process: ( skip variable in file and give exstracted number)
*/
int skipVariable (int SKIP_NUMBER);
// Main function/program
int main ()
{
// initalize function/variables
ifstream fin;
string IN_FILE_NAME, OUT_FILE_NAME;
int SKIP_NUMBER;
//Print Program Title
//Function Name: programTitle
programTitle();
//Prompt user for input file name and skip number
//Function Name: promptUser
promptUser ( IN_FILE_NAME, OUT_FILE_NAME, SKIP_NUMBER);
//Check it file is usable and openable
//Function Name: openInputFile
openInputFile( fin, IN_FILE_NAME);
//Skip variable number
//Function Name: skipVariable
skipVariable ( SKIP_NUMBER);
//Close input file
fin.close();
// make spaces before program end
cout << endl << endl;
// End program
system( "pause" );
return 0;
}
// Supporting function implementation
//
//Display Program Title
void programTitle()
{
// output prompt string
cout << " DECODER PROGRAM" << endl;
cout << " ===============";
cout << endl << endl;
// void function - no return
}
//Prompt user for Input
void promptUser ( string &IN_FILE_NAME, string &OUT_FILE_NAME, int &SKIP_NUMBER)
{
//prompt for an input file name
cout << "Enter input file name: " ;
cin >> IN_FILE_NAME;
cout << endl;
//Prompt for an output file name
cout << "Enter output file name: " ;
cin >> OUT_FILE_NAME;
cout << endl;
//Prompt for number of items to skip
cout << "Enter number of items to skip: " ;
cin >> SKIP_NUMBER;
cout << endl << endl << endl;
// Print process data indication
cout << "Processing Data . . ." << endl << endl;
//void function no return
}
//Function opens file and checks if file exists
bool openInputFile( ifstream &inf, const string &fileName )
{
// clear and open input file
inf.clear();
inf.open( fileName.c_str() );
// return input file condition
return inf.good();
}
//Functio skips variables and returns needed integer
int skipVariable (int SKIP_NUMBER)
//Is the file good/usable
{
//start loop skip valued variable
//get number representing character
//output as file character
// return values
return 0; //temporary return
}