Cannot find a way to define my functions..
Jan 20, 2011 at 4:24am UTC
I have a big function problem. I am trying to make a program that writes the user input to a file until the user inputs '*'. Then closes the file, reopens it and displays whatever it has written to it.. I tried to compile it so i can test it but i get and error in the while loop. I need help defining my functions. Here is what my code looks like so far..
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
//This program will create and display the contents of a text file.
#include <iostream>
#include <fstream>
using namespace std;
//Prototypes
void UserInput();
void WritetoFile();
void ReopenFile();
void CloseFile();
int PerformCalc();
const char asterisk = '*' ;
int main(){
struct Inventory {
int inventoryNumber, markup;
string itemDescription;
double unitCost; };
//Calling functions
UserInput();
return 0;
}
//***********************************
//Defining UserInput *
//***********************************
UserInput()
while (Inventory != asterisk)
}
cout << "Enter Inventory number" ;
cin>> inventoryNumber;
cout << "Enter Item Description" ;
cin>> itemDescription;
cout << "What is the Unit Cost?" ;
cin>> unitCost;
cout << "What is the Markup percent?" ;
cin>> markup;
WritetoFile()
else {
CloseFile()
cout << "Done inputing data" ;
}
//***********************************
//Defining WritetoFile *
//***********************************
fstream writefile;
writefile.open("PRODUCT.TXT" );
//***********************************
//Defining CloseFile *
//***********************************
fstream closefile;
closefile.close("PRODUCT.TXT" );
//***********************************
//Defining ReopenFile *
//***********************************
ifstream reopenfile;
reopenfile.open("PRODUCT.TXT" );
PerformCalc()
reopenfile >> inventoryNumber;
reopenfile >> itemDescription;
reopenfile >> unitCost;
reopenfile >> markup;
//***********************************
//Defining PerformCalc *
//***********************************
Jan 20, 2011 at 4:30am UTC
You have some brace errors. Functions need to open with {, and close with }. All other { need to also be matched with a }. You also need to include the return type of your functions in your implementation as well.
Topic archived. No new replies allowed.