I have the following for loop
:
string temp;
int responseInt[10][10] = { {0,0,0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0,0,0}};
for (int i = 0; i < numberPros; i++)
{
for (int j = 0; j < numberRes; j++)
{
cout << "Is " << process[i] << " holding (h), requesting (r), or doing nothing (n) to " << resources[j] << " ?: ";
cin >> temp;
if (temp == 'n')
responseInt[i][j] = 0;
else if (temp == 'h')
responseInt[i][j] == -1;
else if (temp == 'r')
responseInt[i][j] == 1;
}
}
However, it's like if the if
statements are ignored, since the default values for responseInt
are never changed, even if I type h
or r
or n
.
I already tried with strings, but the same thing happens.
Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire