Go Down

Topic: input from barcode (Read 2 times) previous topic - next topic

maddave

Quote
use strcmp() to compare buffer


sorry but how do i do this....This is the first time i have seen " stcmp() " i have tried looking it up but have had little success


thanks

PaulS

Code: [Select]
char *goodCards = {"12345", "Jones", "Smith", "Stolen" };

int cardCnt = sizeof(goodCards)/sizeof(goodCards[0]);

int goodMatch = -1;

for(int c=0; c<cardCnt; c++)
{
   if(strcmp(buffer, goodCards[c]) == 0)
   {
      goodMatch = c;
      break;
   }
}

Serial.print("goodMatch  = ");
Serial.println(goodMatch);     // Will print index of good card in array

maddave

sorry i just dont get it .... at all !!!!!

PaulS

Quote
sorry i just dont get it

OK. Not too worry.

Where have you defined the names/values of the barcodes that you want to check the scanned on against? That is the (global) array that I called goodCards. If you have another name, we can use that instead.


maddave

if i understand you your asking for a list of coodcard bar code's

if so here they are

3455192327218 card 1
4005209057240 card 2
5060048310337 card 3

thanks for your time

Go Up