How is this working? In writing this function, I forgot to include a return statement:
char *getV(const char *var) {
    char *val = nullptr;
    forward_list<formField>::iterator idx;
    formField ffld;
    idx = _fields.begin();
    while (idx != _fields.end()) {
        ffld = *idx;
        if (strcmp(ffld.Name, var) == 0) {
            val = ffld.Val;
            break;
        }
        idx++;
    }
}
Here is formField:
struct formField {
    char    *Name   = nullptr;
    char    *Val    = nullptr;
};
Here's how I'm calling the function:
int main () {
    form fdata;
    fdata.add("FirstName", "Alan");
    char *fval = fdata.getV("FirstName");
    if (fval != nullptr) cout << fval;
    else cout << "not found";
    cout << "\n";
}
I didn't notice the missing return until later, after testing the function and writing other code which uses it. The function is supposed to return *val...and it does! How?
 
     
    