I am trying to read a file from fstream in a switch statement but something in the code seems to be stopping this part of my code to be read by the compiler. Please some one let me know what am I doing wrong. Its not the text file thats having problem, for sure.
#include "stdafx.h"
#include <iostream>
#include<fstream>
#include<iomanip>
#include<stdlib.h>
using namespace std;
int main()
{
char option = '\0', user;
cout<< setiosflags(ios::left)<< "\t \t \t UH Visitors Parking "<<endl;
cout<< setiosflags(ios::left)<< "_______________________________________________________________"<<endl;
cout<<"\n"<<setiosflags(ios::right)<< "\t Help \t Car \t MotorCycle \t SeniorCitizen \t Quit";
cout<<"\n"<<setiosflags(ios::left)<<"_______________________________________________________________"<<endl;
cout<<"Please select an option from above."<<endl;
cin>> option;
switch(option)
{
case 'H':
//case 'h':
cout<<"Hello."<<endl;
ifstream input("Help.txt");
if(input.fail())
{
cout<<"File not found."<<endl;
}
//if( user = '\n')
exit(0);
break;
}
return 0;
}
Also I had another question.
My assignment asks me, when the user presses enter or so after reading the file, the screen should get clear and display the above menu again. But I wasn't sure how would I clear the screen. I see that I can display the menu by using a loop but not sure about clearing screen. Any ideas for this will be appreciated.
Thanks.