#std:string giving me an error

18 messages · Page 1 of 1 (latest)

latent spearBOT
#

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.

faint snow
#

Gotta show relevant code

solid kiln
#

@modest rain what code is causing the error

modest rain
#

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

solid kiln
#

also [](char c) { return ::isalnum(c); } should be [](char c) { return ::isalnum((unsigned char)c); }

modest rain
#

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

latent spearBOT
#

@modest rain Has your question been resolved? If so, type !solved :)

modest rain
#

ok mb it was something else

#

ty anyways for ur time

#

!solved

latent spearBOT
#

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