here is one issue: you define it but give it no value, and its only chance to get a value is INSIDE a condition. Presumably, the condition COULD be false sometimes, and the variable NEVER get a value. If you then USE the variable, you have a problem!
solution:
int kaina{defaultvalue}; //defaultvalue can be like {0} or {} or {42} or {variable} etc.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
int kaina; //FIX ME
ifstream infile("pricedata.txt");
for (string line; getline(infile, line);)
{
if (line.length() > 3 && line[0] != '/' && line[1] != '/')
{
auto ex = explode("|", line);
if (ex[0] == to_string(id))
{
kaina = atoi(ex[1].c_str());
break;
}
}
}
/*if (kaina == 0) continue;*/ //second kaina fix?
I don't know what the code does or anything about 'should'.
all I know is that if the loop does not execute or if the loop executes and the if statement is false, you have a condition where it 'could' fail to initialize the variable. If you used it after that, it will complain. If the file is empty, it will not assign a value.
there may be other such constructs in your code. I didn't look at every possible logical failure but instead I am showing you an example of what not to do. In any of your blocks, if you have an uninitialized value and it is only assigned conditionally, it can fail there. I will leave you to look for them all. As a side note, its a lot harder to debug stuff when you reuse the same variable name over and over in different scopes.