So I haven't reached the for loop yet, because I am trying to set up the arguments. However, I get a few error messages.
error C2365: 'test_addToFile' : redefinition; previous definition was 'data variable'
error C2065: 'string' : undeclared identifier
error C2146: syntax error : missing ')' before identifier 'names'
error C2182: 'test_addToFile' : illegal use of type 'void'
error C2059: syntax error : ')'
The syntax errors confuse me, because as far as I can tell, things look fine.
I can't find a straight forward explanation of "illegal use of type void"? Again, I tried following the syntax above, but the compiler doesn't agree. Here is my code below. I feel like I've been following instructions I've been receiving to the teeth, but nothing seems to be working.
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
|
/*This is an outline for a simple program I am building that simulates a sales company.
It first gets the name of the employees, along with the sales figures they made this quarter.
The names and sales figures will then be written into a file, and will later be read back to the screen should the user choose to do so.
I left my comments as to help avoid confusion. */
#include<iostream>
#include<iomanip>
#include<fstream>
#include<string>
void testShow_Menu(); // stub for menu
void test_addToFile(string names[], string sales[], int size); // stub for adding names and sales to file
void test_showSalesReport(); // stub for showing sales report
const int SIZE = 10;
using namespace std;
int main()
{
testShow_Menu(); // stub to test Show_Menu function
}
/*
Written on Oct 22, 2015.
Precondition: As the program powers on, the menu is diplayed
giving vthe choice to add to file, view sales or exit.
Post Condition: User makes a selection, passing the choice to a
switch statement calling the appropriate function*/
void testShow_Menu()
{
string fileName;
string names[SIZE];
string sales[SIZE];
cout << "Enter a file name: ";
getline(cin, fileName);
cout << "Welcome To our Sales Program!" << endl;
cout << "What would you like to do?" << endl;
cout << endl;
cout << setw(20) << "1 - Add to sales " << endl;
cout << setw(25) << "2 - View sales report " << endl;
cout << setw(11) << "3 - Exit" << endl;
int choice;
cin >> choice;
switch (choice)
{
case 1:
//test_addToFile();
break;
case 2:
test_showSalesReport();
break;
case 3:
break;
default:
cout << "Invalid choice. Please enter a number 1-3 or type 3 to exit. "; // prevents invalid input into program.
}
}
void test_addToFile(string names[], string sales[], int size)
{
string testName[SIZE], testSales[SIZE];
ofstream out_file;
ifstream in_file;
cout << "This is add to file";
| |