Hi guys, im still learning some programming, and am confused on the subject of file i/o. I am getting this error but cant figure out why. Any help is appreciated, thanks
Keep in mind i have obviously not finished the case scenarios.
In function `int main()':
error: jump to case label
error: crosses initialization of `std::ofstream cList'
error: jump to case label
error: crosses initialization of `std::ofstream cList'
error: `repeat' undeclared (first use this function)
error: (Each undeclared identifier is reported only once for each function it appears in.)
warning: destructor needed for `cList'
warning: where case label appears here
warning: (enclose actions of previous case statements requiring destructors in their own scope.)
warning: destructor needed for `cList'
warning: where case label appears here
Execution terminated
#include <iostream>
#include <fstream>
#include <windows.h>
#include <string>
using namespace std;
string catEnter;
string itEnter;
int main()
{
SetConsoleTitle("ItemIzer");
cout<<"\n\n\n\n";
cout<<"\t1: View Catagory"<<endl;
cout<<"\t2: Append new item"<<endl;
cout<<"\t3: Delete an item"<<endl;
cout<<"\t4: Create Catagory"<<endl;
cout<<"\t5: Delete Catagory"<<endl;
do
{
int cho;
bool repeat(false);
cout<<">>";
cin>>cho;
switch (cho)
{
case 1:
case 2:
case 3:
case 4:
ofstream cList;
cout<<"Catagory Name>>";
cin>>catEnter;
cList.open ("Catagories.txt", ios::app);
cList<<catEnter;
cList.close();
cin.get();
break;
case 5:
default:
cout<<"Bad user input, please select a menu option";
repeat = true;
}
}
while (repeat);
}