Clear variable value

Hi,

I am developing a POS terminal application. In my case I am using NFC to communicate with NFC card using APDU's. I want to communicate continually so to do that I am using a for loop. My problem is, when I pass first APDU into card it will execute successfully.But the second time and other times the index of the for loop is always contains "0" value. After send the APDU the incremented index value is erased. Can anyone help me??

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

int i = 0;

for(i=0;i<5;i++){
    print(i);
    sendAPDU(); // APDU sending function
    print(i);
    newLine();
}


/*
 output
 
 00
 10
 10
 10
 10 

*/
Hi,

I solved it. I developed a separate function to call to sendAPDU() function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

void separateFunction(){
    sendAPDU(); // APDU sending function
}

void myMethod(){
   int i = 0;

   for(i=0;i<5;i++){
       print(i);
       separateFunction();
       print(i);
       newLine();
   }
}
Topic archived. No new replies allowed.