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.
18 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.
Gotta show relevant code
@modest rain what code is causing the error
this is in the middle of a function
string password = extract_password(it, end);
if (password == "") {
return "ERR";
}
functions:
string extract_password(string::iterator &it, string::iterator end) {
string password = extract_sized_word(it, end, 8);
cout << "|" << password << "|" << endl;
if (is_valid_password(password)) {
cout << "no pass" << endl;
return "";
}
cout << "yess pass" << endl;
return password;
}
bool is_valid_password(const string &str) {
if (!(str.length() == 8 && all_of(str.begin(), str.end(), [](char c) { return ::isalnum(c); }))) {
cerr << "Invalid Password: " << str << endl;
return false;
}
return true;
}
i know that this line if (is_valid_password(password)) { i was missing a '!' char in the expression, still i cant understand what happen
std::string::length_error is thrown when the string created is way too large
maybe you're providing iterators to unrelated objects which is causing this error?
also [](char c) { return ::isalnum(c); } should be [](char c) { return ::isalnum((unsigned char)c); }
the iterators it and end are pointing to a a string that contains "LIN 103600 12345678\n"
end is str.end()
it starts at the str.begin() and goes foward in the string
it stops on \n
when i do *it it points to \n
didn't know ty
@modest rain Has your question been resolved? If so, type !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