so im new to c++ and i have a project that i am currently doing in school however im stuck on how to get an entire row of info from a user input selection.
here is what my txt file looks like
1 Home Work 5
2 Work Home 5
3 Home School 6
4 School Home 6
5 Work School 8
6 School Work 8
so basically if they input/ cin option 3 but how do i print and obtain the values in row 3 to display and compute later on?
heres my code
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdlib.h>
#include <string>
#include <cstdlib>
#include <Windows.h>
#include <cmath>
void bookingmenu();
void confirmedbooking(double calc);
double calc;
using namespace std;
int main()
{
ifstream inFile;
string PUP, Dropoff, others, otherstwo;
double distance = 0, calc;
string ON;
int sel;
char choice;
inFile.open("blist.txt");
if (!inFile)
cout << "Error, unable to open text file.\n" << endl;
else
cout << left << fixed << setprecision(2);//how many dp
cout << left << setw(25) << "Option Number" << left << setw(25) << "Pick Up Point" << "Dropoff Point" << endl; //display column header
while (!inFile.eof())
{
inFile >> ON >> PUP >> Dropoff;
if (inFile.fail()) break;
cout << left << setw(25) << ON << left << setw(25) << PUP << Dropoff << endl;
}
cout << "Please select an option for your trip: ";
cin >> sel;
//(im stuck after here)
cout << "You have selection option number " << ON << " and your pickup point is " << PUP << " and your dropoff point is " << Dropoff << endl;
system("pause");
return 0;
}