ruriz
Newbie level 1
- Joined
- Feb 4, 2015
- Messages
- 1
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 8
Hello, So I have this simple code that I am trying to understand in able to build an UTP lan tester
I would appreciate if someone can help me with this
so here is my code
assume we have an array of three types of cables and an array with a pointer to pass variables
my question is what does 'ok' do in this code , and why do I have to set it back to zero and use an if loop to return the type?
I would appreciate if someone can help me with this
so here is my code
assume we have an array of three types of cables and an array with a pointer to pass variables
Code:
int findType(int *v){ // the cable types
int straight[8] = {1, 2, 3, 4, 5, 6, 7, 8};
int cross[8] = {3, 6, 1, 4, 5, 2, 7, 8};
int roll[8] = {8, 7, 6, 5, 4, 3, 2, 1};
int i, ok = 0;
for(i = 0; i < 8; i++){
if(v[i] != straight[i]){
ok = 1;
break;
}
}
if(ok == 0)
return 0;
ok = 0;
for(i = 0; i < 8; i++){
if(v[i] != cross[i]){
ok = 1;
break;
}
}
if(ok == 0)
return 1; // type if cable
ok = 0;
int type;
int v[8] = {0, 0, 0, 0, 0, 0, 0, 0};
//etc etc
my question is what does 'ok' do in this code , and why do I have to set it back to zero and use an if loop to return the type?