enroll_label: printf("*****************Enroll Finger Test*****************\n"); nRet = ZAZ_NO_FINGER; printf("1. Enroll: Please press finger1......\n"); while(nRet == ZAZ_NO_FINGER) { nRet=ZAZGetImage(nhanle,DEV_ADDR); counts++; if(counts > 10000000) printf("wating time over......\n"); else printf("wating time %d......\n",counts); } if(nRet != ZAZ_OK) { printf("ZAZGetImage is Fail ,errorr code = %d......\n",nRet); return 0; } printf("2. ZAZGetImage ok......\n"); //BYTE pImage[256*288]; //int nImageLen; //ZAZUpImage(DEV_ADDR,pImage,&nImageLen); //ZAZImgData2BMP(pImage,"fp.bmp"); nRet = ZAZGenChar(nhanle,DEV_ADDR,BUFFER); if(nRet != ZAZ_OK) { printf("ZAZGenChar is Fail ,errorr code = %d......\n",nRet); goto enroll_label; } printf("3. ZAZGenChar ok Buffer = %d......\n",BUFFER); BUFFER++; if(BUFFER < 3) goto enroll_label; nRet = ZAZRegModule(nhanle,DEV_ADDR); if(nRet != ZAZ_OK) { printf("ZAZRegModule is Fail ,errorr code = %d......\n",nRet); BUFFER = 1; goto enroll_label; } printf("4. ZAZRegModule ok \n"); nRet = ZAZStoreChar(nhanle,DEV_ADDR,CHAR_BUFFER_A,1); if(nRet != ZAZ_OK) { printf("ZAZStoreChar is Fail ,errorr code = %d......\n",nRet); BUFFER = 1; goto enroll_label; } printf("5. ZAZStoreChar ok id = %d\n",1); printf("*****************END*****************\n");这段代码转话成没有goto的写法
时间: 2023-08-06 11:10:09 浏览: 104
可以使用循环和条件语句来代替goto的写法,如下所示:
```c
printf("*****************Enroll Finger Test*****************\n");
int buffer = 1;
int counts = 0;
while(buffer < 3) {
printf("%d. Enroll: Please press finger%d......\n", buffer, buffer);
int nRet = ZAZ_NO_FINGER;
while(nRet == ZAZ_NO_FINGER) {
nRet = ZAZGetImage(nhanle, DEV_ADDR);
counts++;
if(counts > 10000000)
printf("wating time over......\n");
else
printf("wating time %d......\n", counts);
}
if(nRet != ZAZ_OK) {
printf("ZAZGetImage is Fail ,errorr code = %d......\n", nRet);
buffer = 1;
continue;
}
printf("%d. ZAZGetImage ok......\n", buffer);
nRet = ZAZGenChar(nhanle, DEV_ADDR, buffer);
if(nRet != ZAZ_OK) {
printf("ZAZGenChar is Fail ,errorr code = %d......\n", nRet);
continue;
}
printf("%d. ZAZGenChar ok Buffer = %d......\n", buffer, buffer);
buffer++;
}
int nRet = ZAZRegModule(nhanle, DEV_ADDR);
if(nRet != ZAZ_OK) {
printf("ZAZRegModule is Fail ,errorr code = %d......\n", nRet);
goto enroll_label;
}
printf("4. ZAZRegModule ok \n");
nRet = ZAZStoreChar(nhanle, DEV_ADDR, CHAR_BUFFER_A, 1);
if(nRet != ZAZ_OK) {
printf("ZAZStoreChar is Fail ,errorr code = %d......\n", nRet);
goto enroll_label;
}
printf("5. ZAZStoreChar ok id = %d\n", 1);
printf("*****************END*****************\n");
```
阅读全文