been learning C++ for couple months and I have now a problem with code that keeps exiting with 0 whenever I try to compile and doesn't give me anything. The idea is to take information from the file, this code is an attempt at parsing it (I used cin and ignore.cin() instead of getline() becuase the file is structured like "type" "food/feeling" "date" end of line). Whenever I run though, there is no error but the compiler says the code exited with 0
My code is posted below, any help is appreciated!
#include <iostream>
#include <vector>
#include <fstream>
#include <string>
using namespace std;
struct Day
{
string date;
vector<string> feeling;
vector<string> food;
};
vector<Day*>* makeFile(struct Day, string);
int main()
{
cout << "Please input file name" << endl;
string fileName;
cin >> fileName;
vector<Day*>* makeFile(Day);
}
//function to read data from file and input to vectors
vector<Day*>* makeFile(struct Day, string fileName)
{
vector<Day*>* days = new vector<Day*>;
vector<string>masterFood;
vector<string>masterFeel;
vector<string>masterDate;
string date;
string newDate;
string type;
string foodName;
string feelingType;
bool exists = false;
ifstream fin(fileName);
while (exists = false)
{
if (fin.is_open())
{
exists = true;
Day* d = new Day;
cin >> type;
cin.ignore();
if (type == "food")
{
cin >> foodName;
d->food.push_back(foodName);
masterFood.push_back(foodName);
}
else if (type == "feeling")
{
cin >> feelingType;
d->feeling.push_back(feelingType);
masterFeel.push_back(feelingType);
}
cin.ignore();
cin >> date;
d->date = date;
days->push_back(d);
while (!fin.eof())
{
cin >> type;
cin.ignore();
if (type == "food")
{
cin >> foodName;
d->food.push_back(foodName);
}
else if (type == "feeling")
{
cin >> feelingType;
d->feeling.push_back(feelingType);
}
cin.ignore();
cin >> newDate;
if (newDate != date)
{
Day* d = new Day;
}
}
}
else
{
cout << "Please enter valid file name" << endl;
}
}
return days;
}