When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
43 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
@minor scarab
Your message appears to contain screenshots but no code. Please send code and error messages in text instead of screenshots if applicable!
int main()
{
vector <Flight> flightsvector;
string line;
string datachannel;
vector<string> seatsvector;
int numofiterations = 60;
int counter = 0;
int i = 0;
bool usercheck = false;
ifstream file("flightlist.txt");
if (!file.is_open()) {
cout << "Error abriendo archivo." << endl;
return 0;
}
while (true) {
flightsvector.push_back(Flight());
//DIVIDER
if (!getline(file, datachannel)) break;
flightsvector[counter].setDate(datachannel);
if (!getline(file, datachannel)) break;
flightsvector[counter].setHour(datachannel);
if (!getline(file, datachannel)) break;
flightsvector[counter].setPrice(stof(datachannel));
if (!getline(file, datachannel)) break;
flightsvector[counter].setAirplaneModel(datachannel);
if (!getline(file, datachannel)) break;
flightsvector[counter].setFromTo(datachannel);
if (!getline(file, datachannel)) break;
flightsvector[counter].setDistance(stof(datachannel));
if (!getline(file, datachannel)) break;
flightsvector[counter].setCrew(datachannel);
if (!getline(file, datachannel)) break;
flightsvector[counter].setFuel(stof(datachannel));
while (i <= numofiterations) {
if (!getline(file, datachannel)) break;
seatsvector.push_back(datachannel);
i = i + 1;
}
flightsvector[counter].setSeats(seatsvector);
counter = counter + 1;
}
file.close();
}
```cpp
int main() {}
```
int main() {}
i recommend checking out value is failing via the debugger
Hello
Value is failing?
i'm very postifive it's the stof lines that are causing the code to not run, as it does fine when i get rid of them
i just cannot seem to figure out why
sure, open a debugger and determine which value is causing stof to fail
i don't think i understand
here's the debugger feature tour link again, if you didn't see/read it before
give me a second
okay
i keep trying to run it by steps but it just
okay wait
i figured it out
i just don't see how this helps
@minor scarab Has your question been resolved? If so, type !solved :)
I mean, if we know what value is causing the issue, that's a huge help 
yeah but i just don't see how running it step by step will tell me what value causes the crash
so far nothing seems out of the ordinary when debugging that way
got past the only uses of stof in the file
well what is the callstack when it does crash?
_Errno_ref and then it sends me here
so it's actual a std::invalid_argument "invalid stof argument", not out of range
check what _Str is there by hovering over it
over invalid stof argument?
no, const string& _Str parameter at the top
ohhh okay i think i'm starting to understand what's going on now
there you go
the lines in the text file likely don't match up with how you're parsing them
oh my GOD it was
the dumbest mistake ever
i just realized what it was
i forgot to reset the vector assigner counter after every loop so after the first loop it just went haywire
it was so SIMPLE
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
THANKS
np 🙂 glad to hear you got it solved