I wrote a program that opens a file using the command line (cmd), calculates a bunch of numbers, then outputs the results to another file.
The program works fine, but when I tried to alter my code using classes, all of a sudden the program is not fine.
Here is a basic outline of my program
void Bank::checkValid()
{
//code here
}
void Bank::outputToFile()
{
//code here
}
int main (int argc, char* argv[])
{
char* inputFileName= new char;
inputFileName= strstr (argv[1],"=")+ 1;
ifstream input;
input.open (inputFileName, ifstream::in);
Bank test;
test.checkValid();
test.outputToFile(); //will output results to another .txt file
return 0;
}
I am thinking the file is not opening correctly as my program is unable to read the first char in my input file.
Does my code look ok?
I wanted to write a method inside my class that will open the file, but I don't know how to do that since I am only allowed to open the file using the cmd. I am thinking there is something wrong with the main body, can someone offer me some advice?