a newbie here, so i was writing a simple code in cpp using array, functions and fstream, apparently this is the first time i see bug like this in my code, i'm not sure what's wrong with it.
I am using 3 IDE; codeblocks, visual studio and devC++. In codeblocks there is no error, however in VS and devcpp there is that error, despite i copypaste the same code. There is a .txt file, but i can't upload it here, basically it's a menu list with food name and price.
Here is my Code:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
using namespace std;
int main()
{
ifstream inputFile;
char user_choice;
const int SIZE = 5;
string menu[SIZE];
float price[SIZE];
inputFile.open("Menu_List.txt");
getline(inputFile, menu[0], '\t');
inputFile >> price[0];
getline(inputFile, menu[1], '\t');
inputFile >> price[1];
getline(inputFile, menu[2], '\t');
inputFile >> price[2];
getline(inputFile, menu[3], '\t');
inputFile >> price[3];
getline(inputFile, menu[4], '\t');
inputFile >> price[4];
getline(inputFile, menu[5], '\t');
inputFile >> price[5];
inputFile.close();
cout << "Are you an Employee / Manager of this Restaurant?\n";
cout << "Press Y you're a manager, N if you're a Customer\n";
cout << "Y/N?\n";
cin >> user_choice;
if(user_choice == 'y' || user_choice == 'Y'){
}
else if(user_choice == 'n' || user_choice == 'N'){
cout << "Welcome valued Customer\n\n" << "Please choose our foods from the Menu below\n";
cout << "Fetching Menu List. . .\n";
for(int i = 0; i < SIZE; i++){
cout << menu[i] << '\t' << '$' << fixed << setprecision(2) << price[i] << endl;
}
}
else{
cout << "Invalid input ERROR, try again from the beginning!!!\n";
return 0;
}
return 0;
}
Aucun commentaire:
Enregistrer un commentaire