So we have a text file with the following data:
Year - Make - Model - Price
2011 Chevrolet Tahoe $30588
There is only 1 space between everything. There is a Dollar Sign ($) in front of the price. How would I go about getting this information from a text file?
I have tried a bunch of methods, and none of them seem to work.
#include <iostream>
#include <string>
#include <fstream>
#include <sstream>
#include <ctime>
#include "car.h"
usingnamespace std;
constint number=3;
constint maxPrice=25000;
int main()
{
int a;
string b; string c;
float d;
float e;
car cars [number];
int i, j;
float temp; //Price
int temp2; //Year
string temp3; //Make
string temp4; //Model
float temp5; //Miles
ifstream inFile; //declaring the File
inFile.open("carData.txt");
for(i=0; i<number; i++)
{
cout << "Enter the YEAR of the car: ";
getline(cin,a);
cars[i].setYear(a);
cout << "Enter the MAKE of the car: ";
getline(cin,b);
cars[i].setMake(b);
cout << "Enter the MODEL of the car: ";
getline(cin,b);
cars[i].setModel(c);
cout << "Enter the number of MILES on the car: ";
cin >> d;
cars[i].setMiles(d);
cout << "Enter the PRICE of the car: ";
getline(cin,e);
cars[i].setPrice(e);
cout << " " << endl;
}
The main continues much further than that, this is just to getline all of the data.