Ok I have to create a program with a loop and switch that has 4 options. Write a name to file, Read name from file, Clear name from file, and Close the program.
I am getting a truck load of errors...
Error 1 error C2062: type 'int' unexpected c:\users\cyount30754\desktop\notagoodmenu\source.cpp 17 1 notagoodmenu
Error 2 error C2065: 'select' : undeclared identifier c:\users\cyount30754\desktop\notagoodmenu\source.cpp 31 1 notagoodmenu
Error 3 error C2065: 'select' : undeclared identifier c:\users\cyount30754\desktop\notagoodmenu\source.cpp 34 1 notagoodmenu
Error 4 error C2065: 'select' : undeclared identifier c:\users\cyount30754\desktop\notagoodmenu\source.cpp 36 1 notagoodmenu
Error 5 error C2050: switch expression not integral c:\users\cyount30754\desktop\notagoodmenu\source.cpp 36 1 notagoodmenu
Error 6 error C2360: initialization of 'name' is skipped by 'case' label c:\users\cyount30754\desktop\notagoodmenu\source.cpp 48 1 notagoodmenu
Error 7 error C2086: 'std::string name' : redefinition c:\users\cyount30754\desktop\notagoodmenu\source.cpp 50 1 notagoodmenu
Error 8 error C2360: initialization of 'name' is skipped by 'case' label c:\users\cyount30754\desktop\notagoodmenu\source.cpp 62 1 notagoodmenu
Error 9 error C2086: 'std::string name' : redefinition c:\users\cyount30754\desktop\notagoodmenu\source.cpp 63 1 notagoodmenu
Error 10 error C2065: 'select' : undeclared identifier c:\users\cyount30754\desktop\notagoodmenu\source.cpp 71 1 notagoodmenu
11 IntelliSense: transfer of control bypasses initialization of:
variable "name" (declared at line 40)
variable "name" (declared at line 50) c:\Users\cyount30754\Desktop\notagoodmenu\Source.cpp 36 4 notagoodmenu
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 74
|
// Cameron Yount
// 11/6/2014
// Assignment 8
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main()
{
const int CHOICE_1 = 1,
CHOICE_2 = 2,
CHOICE_3 = 3,
CHOICE_4 = 4,
int select;
int name;
ofstream outputFile;
ifstream inputFile;
do
{
cout << "Select and Option: " << endl;
cout << "1. Add Name to File." << endl;
cout << "2. Display Name on File." << endl;
cout << "3. Clear the File." << endl;
cout << "4. Exit the Program." << endl;
cout << "Selection: ";
cin >> select;
cout << endl;
if (select != CHOICE_4)
{
switch (select)
{
case CHOICE_1:
string name;
outputFile.open("names.txt", ios::app);
cout << "Add a Name to File." << endl;
cout << "Enter a name: ";
cin >> name;
break;
case CHOICE_2:
string name;
inputFile.open("names.txt");
cout << "Names from the file names.txt: " << endl;
cout << endl;
while (inputFile >> name)
{
cout << name << endl;
}
cout << endl;
inputFile.close();
break;
case CHOICE_3:
string name;
outputFile.open("names.txt");
cout << "All data cleared." << endl;
outputFile.close();
}
}
} while (select != CHOICE_4);
system("pause");
return 0;
}
|
HALP!