Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Creating and implementing functions (C++).
#15
I agree, the second one is much simpler. Thanks. I pretty much have all of the calculating functions down. I have one more function to work on, and that is to copy the input file's values into an output file, with two values per line... I think I'll be saving that for last, in case I do manage to miraculously solve that.

Buuut this is getting embarrassing. I just keep running into problems I just really can't solve by myself. Programming is hard. ;__;

"Required Input/Output Formats:

Input Prompt: Enter Name of Input File:
Enter Name of Output File: "

I'd just noticed this, so I'm wondering how this needs to work. I had a premade file and had the program open that ( inF.open("NameOfFile.txt"); ) before realizing I couldn't just do that; it looks like the program needs to locate the file I want to use in case I was using a different file name.

Code:
int main()
{
    ...
    ifstream inF;                    //Declared input file.
    ofstream outF;                    //Declared output file.

    cout << "Enter Name of Input File: " << inF << endl;
    cout << "Enter Name of Output File: " << outF << endl; //PRETTY SURE THESE TWO LINES ARE WRONG.

    inF.open(???);                    //Opens input file.

    if(inF.fail())                    //Checks if the file was opened successfully.
    {
        return 1;                //Terminates program if file is not found. MAY NEED TO USE EXIT INSTEAD OF RETURN, UNSURE HOW.
    }

    outF.open(???);                    //Opens output file.
    ...
}

On a side-note, I could really use some sleep right now.
Reply


Messages In This Thread
Creating and implementing functions (C++). - by MariettaRC - 2013-09-16, 06:53 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)