2020-09-06 09:11 PM
I have a code made to check an if statement and then perform something. here is the if statement
for(int j=0;j<10;j++)
{
if(removed_Num==USERS[j])
{ //do something}
}
USERS[j] is a 13 element array and removed_Num is also a 13 element array. I've check in the debug mode and saw USERS[j] is equal with removed_Num. but it doesn't enter the if statement. why is that?
Solved! Go to Solution.
2020-09-06 11:30 PM
Clive1 is right.
If you compare two array with all indexes, you need select index one by one and compare them.
I wrote a example,
Not; if you make this with while not for, it can will work faster.
I hope you understand clearly.
2020-09-06 10:51 PM
As described that isn't how C works.
The comparison here is of the address of an array vs the element in a second array. You basically ask it to compare apples and oranges, which usually they don't.
2020-09-06 11:07 PM
so what's the right way to do it?
2020-09-06 11:30 PM
Clive1 is right.
If you compare two array with all indexes, you need select index one by one and compare them.
I wrote a example,
Not; if you make this with while not for, it can will work faster.
I hope you understand clearly.
2020-09-07 12:00 AM
thank you all guys! you're amazing!:)