0

I've been banging my head trying to figure this one out. I would love to have a couple of you have a crack at it because I'm all out of ideas.

bool characterGetCFG1(string typeOverLoad, string var_name, string full_text) {
int pos = full_text.rfind(var_name) + var_name.length() + 1;
char character = full_text.at(pos);
if (character == 't' || 'T') {
    cout << full_text << "\n";
    cout << "features.assigned, " << var_name << ", " << full_text.at(pos) << ".\n";
    cout << "returned true \n";
    cout << character << "\n";
    return true;
}else{
    cout << "returned false \n";
    return false;
}

void setconfig(glow_t passed_glow) {
ifstream file;

file.open("config.cfg");
if (!file.is_open()) {
    exit(-10);
}
std::string raw;
while (file.good()) {
    raw.assign(std::istreambuf_iterator<char>(file), std::istreambuf_iterator<char>());
    file >> raw;
}
file.close();

feats.setGlow(characterGetCFG1("t", "glow", raw));

Don't worry about the brackets I have the correct amount in project, I coulnd't fit them all in the code tag sadly.

EDIT: I forgot to incldue the 'config.cfg' file here ya go below.

glow=false

2 Answers2

1
(character == 't' || 'T')

Always evaluates to true, becase 'T' always evaluates to true. You probably intended to write if (character == 't' || character == 'T')

William Pursell
  • 204,365
  • 48
  • 270
  • 300
1

You need

character == 't' || character == 'T'

This:

character == 't' || 'T'

is the same as

(character == 't') || ('T' != 0)

which is always true because of the 'T' on the right hand side.

Petr Skocik
  • 58,047
  • 6
  • 95
  • 142